# /api/v1/accounts

The response schema:

```javascript
interface v1_AccountsResponse extends Base_ApiV1 {
  accounts: Array<Account_ApiV1>;
  pagination: PaginationResponse_ApiV1;
}
```

You can find the `Base_ApiV1` and the `PaginationResponse_ApiV1` interface here:

{% content-ref url="schema" %}
[schema](https://debitllama.gitbook.io/debitllama/rest-api-v1/schema)
{% endcontent-ref %}

Accounts Object contains the following parameters:<br>

```typescript
 {
  id: number;
  created_at: string;
  network: {
     name: string;
     rpc: string;
     chain_id: string;
     currency: string;
     virtual_accounts_contract: string;
     connected_wallets_contract: string;
     available_currencies: Array<{name: string,native: boolean,contract_address: string}>
   }
  commitment: string;
  name: string;
  closed: boolean;
  currency: {name: string,native: boolean,contract_address: string}                           };
  balance: string;
  account_type: "VIRTUALACCOUNT" | "CONNECTEDWALLET"
  creator_address: string;
}

```

* id - A unique numeric identifier for the account
* created\_at - Account creation UTC date string
* network - The details of the network the account is connected to
* commitment - The unique identifier of the account, useful for querying the blockchain with.
* name - The name of the account
* closed - The status of the account, closed accounts are not usable anymore.
* currency - The currency the account is using
* balance - The account balance in the currency. Formatted Eth string! To convert to wei you need to parseEther
* account\_type - The account type determines which smart contract the account is using. Spell it using all caps
* creator\_address - The address of the account creator

The accounts can be sorted by using these parameters:

```javascript
enum Accounts_sortBy {
  created_at = "created_at",
  network_id = "network_id",
  name = "name",
  account_type = "account_type",
  creator_address = "creator_address",
  currency = "currency",
  balance = "balance",
  closed = "closed",
  last_modified = "last_modified
}
```

An Example GET request to fetch accounts sorted by network\_id

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

* current\_page - The current page number to fetch. Pages are indexed from 0 and defaults to 0
* page\_size - Override the default page size. It will determine the total pages based on the count of results defaults to 0
* sort\_by - See the Accounts\_sortBy enum for the accepted values. Defaults to created\_at
* sort\_direction - DESC or ASC . Defaults to DESC

#### Filtering

You can request to filter the responses using the `filter` query parameter which must contain a JSON string! See the below pseudo code:&#x20;

<pre class="language-javascript"><code class="lang-javascript"><strong>const filter = JSON.stringify({
</strong>  network_id : string, // Must be a chain_id from supported_networks returned by /api/v1
  name : string, // The exact name of the accout
  account_type : "CONNECTEDWALLET" | "VIRTUALACCOUNT", // The account type must be all caps
  creator_address : string, // A valid ETH address that created the account
  currency : string, // The currency parameter must be a JSON string 
  balance : string, // The exact account balance we want to fetch in ETH
  closed : boolean, // true if the account is closed
});
</code></pre>

All the **parameters of the filter are optional**, you should only include the parameters you want to match exactly.

Here is an example GET request URL to fetch all active accounts (closed: false) on network BTT Testnet (network\_id: 0x405) created by the access token creator&#x20;

```
https://debitllama.com/api/v1/accounts?filter={"closed": false,"network_id":"0x405"}
```

{% hint style="warning" %}
Note about filtering currencies: \
The currencies stored by the back-end are JSON strings with the following interface:\
{\
&#x20; name: string,\
&#x20; native: boolean,\
&#x20; contractAddress : string

}\
You must filter for them using a JSON string, else it won't work.\
Query the /api/v1 endpoint for available currencies per network and JSON.stringify() before you pass it as filter parameter!
{% endhint %}


---

# 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/api-v1-accounts.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.
