# 5. Data Debits

### Data Debits

#### Get all the Data Debits

The are 2 ways to fetch data debits:

1. With default options.

Response:

* Array<[DataDebit](https://docs.dataswift.io/guides/data-debits/01-data-debit-proposal)>: An array of Data Debits.

**Example:**

```typescript
try {
    const result = await hat.dataDebits().getAllDefault();

    if (result.parsedBody) {
        // result.parsedBody contains an array of Data Debits.
    }
} catch (error) {
    // Failed to fetch Data Debits.
}
```

2\. With custom options.

| Parameters | Type   |
| ---------- | ------ |
| options    | Object |

Response:

* Array<[DataDebit](https://docs.dataswift.io/guides/data-debits/01-data-debit-proposal)>: An array of Data Debits.

**Example:**

```typescript
// In custom options you can specify the following parameters: "ordering", "orderBy", "take", "skip"
const options = {
    ordering: "descending",
    orderBy: "name"
};

try {
    const result = await hat.dataDebits().getAll(options);

    if (result.parsedBody) {
        // result.parsedBody contains an array of Data Debits.
    }
} catch (error) {
  // Failed to fetch Data Debits.
}
```

#### Get a Data Debit with a specific ID

| Parameters  | Type   |
| ----------- | ------ |
| DataDebitId | string |

Response: [DataDebit](https://docs.dataswift.io/guides/data-debits/01-data-debit-proposal): The Data Debit object.

**Example:**

```typescript
try {
    const result = await hat.dataDebits().getById("your-data-debit-id");

    if (result.parsedBody) {
        // result.parsedBody contains the data debit.
    }
} catch (e) {
  // Failed to get Data Debit by ID...
}
```

#### Get Data Debit values

| Parameters  | Type   |
| ----------- | ------ |
| DataDebitId | string |

Response:

* DataDebitValues: The Data Debit values bundle.

**Response type:**

```typescript
interface DataDebitValues<T> {
  bundle: { [endpoint: string]: Array<HatRecord<T>> };
}
```

**Example:**

```typescript
try {
    const result = await hat.dataDebits().getDataDebitValues("your-data-debit-id");

    if (result.parsedBody) {
        // result.parsedBody contains the bundle.
    }
} catch (error) {
  // Failed to get Data Debit values...
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dataswyft.com/build/advanced-topics/pda-authentication/password-management/tutorials/data-api/5.-data-debits.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
