# Schema

```typescript
interface Base_ApiV1 {
  _self: Link; // This is the Link of the current endpoint
  _version: "v1"; // The Api version
  _description: string; // A short desciption of what the endpoint does
  _links: Array<Link>; // Hyperlinks to navigate to from here
}
```

The base response is implemented by all endpoints. It serves to make the API self descriptive.

All endpoints provide hyperlinks to help navigate the API and will list the available HTTP Request methods that are supported.

```typescript
interface Link {
  href: string;
  methods: Array<Methods>
}

enum Methods {
  GET = "GET",
  POST = "POST",
  DELETE = "DELETE",
  PUT = "PUT",
}

```

#### Errors

The API will return errors using this generic interface. If the response status is not 200, then you can expect to find an error message in the response.&#x20;

```javascript
interface ErrorResponse extends Base_ApiV1 {
  error: Error;
}

interface Error {
  message: string; // The error message
  status: number; // The returned error code
  timestamp: string; // The timestamp, it is always UTC time
}
```

#### Pagination

Endpoints that return multiple results implement a Pagination interface that will let you query for lists paginated. You can identify these endpoints as they don't support \[slug] parameter, which is used for fetching data individually and we will discuss it later.

The endpoints that support pagination will return these parameters:<br>

```typescript
interface PaginationResponse_ApiV1 {
  current_page: number; // The current page returned
  total_pages: number; // The total pages available for the current page size!
  page_size: number; // Defaults to 10. This is used together with current_page and total_pages to determine page content
  sort_by: string; // The column that is currently sorted in this response
  sort_direction: string; // The ordering of the sorted column. Values can be  "ASC" or "DESC"
  sortable_columns: Array<string>; // This returns the list of valid column names that can be sorted
}

```

When using Pagination, the request url can contain the following query parameters:

```javascript
interface PaginationSearchParams_ApiV1{
  current_page: number | undefined;  // The current page we are requesting, defaults to 1 if undefined 
  page_size: number | undefined;  // The size of the pages, used to override the default value : 10
  sort_by: string | undefined; // The column name to sort by, defaults to "created_at" when undefined
  sort_direction: string | undefined; // The ordering for the sorted column. Values can be "ASC" or "DESC" defaults to "DESC" if undefined"
}
```

If any of these are missing from the request, the default parameters are used.

A paginated GET request would have the following URL parameters:

```
https://debitllama.com/api/v1/accounts?current_page=1&page_size=20&sort_by=network_id&sort_direction=DESC
```

This will fetch a page with a custom page size, sorted by network\_id

Filtering is available when fetching collections.\
The applied filters are returned as a collection of filters

```typescript
filters: Array<Filter>

interface Filter {
  parameter: string;
  value: string;
}

availableFilters: Array<string>
```

While available filters are returned as an array of strings!

To use a filter you must use the filter query parameter in the URL and JSON encode your parameters

Example:

```javascript
const filter = JSON.stringify({
  network_id : "0x405", 
  account_type : "VIRTUALACCOUNT", 
  closed : false, 
});

https://debitllama.com/api/v1/accounts?=filter${filter}

```

This request will return all open virtual accounts on the network 0x405 using the default pagination


---

# 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://debitllama.gitbook.io/debitllama/rest-api-v1/schema.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.
