# Balances and transactions

### Endpoint

{% code overflow="wrap" %}

```http
https://us.market-api.kaiko.io/v2/data/wallet.v1/audit
```

{% endcode %}

### Parameters

<table><thead><tr><th width="220">Parameter</th><th width="211">Description</th><th width="208">Example</th><th data-type="checkbox">Required?</th></tr></thead><tbody><tr><td><code>blockchain</code></td><td>Always <code>solana</code>.</td><td><code>solana</code></td><td>true</td></tr><tr><td><code>sort</code></td><td>The sorting order for the results.</td><td><code>asc</code> or <code>desc</code></td><td>false</td></tr><tr><td><code>page_size</code></td><td><p>Number of results to return data for. (max: 5000).</p><p>See <a href="https://docs.kaiko.com/kaiko-rest-api/general/getting-started/pagination">Pagination</a></p></td><td><code>100</code></td><td>false</td></tr><tr><td><code>start_time</code></td><td>Starting time in ISO 8601 (inclusive).</td><td><code>2022-05-01T00:00:00.000Z</code></td><td>false</td></tr><tr><td><code>end_time</code></td><td>Ending time in ISO 8601 (inclusive).</td><td><code>2022-05-01T00:00:00.000Z</code></td><td>false</td></tr><tr><td><code>transaction_hash</code></td><td>Filter by transaction hash.</td><td><code>syJFDzPJJ92GLsXqYXUKEY23e8uoLPAdgci7Ko9cUYZxvCvf5SHdKnYuC1Jh7UrTSzRc2EpUB7kzCwGd2qdTnKD</code></td><td>false</td></tr><tr><td><code>user_address</code></td><td>Filter by user address.</td><td><code>2AXXcN6oN9bBT5owwmTH53C7QHUXvhLeu718Kqt8rvY2</code></td><td>false</td></tr><tr><td><code>token_address</code></td><td>Filter by token address. </td><td><a data-footnote-ref href="#user-content-fn-1"><code>EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v</code></a></td><td>false</td></tr><tr><td><code>token_symbol</code></td><td>Filter by token symbol.</td><td><a data-footnote-ref href="#user-content-fn-2"><code>SOL</code></a></td><td>false</td></tr></tbody></table>

### Fields

| Field               | Description                                                                                                                                                             | Example                                                                                   |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `chain`             | Blockchain name.                                                                                                                                                        | `solana`                                                                                  |
| `block_number`      | The height of the block.                                                                                                                                                | `328800011`                                                                               |
| `timestamp`         | The timestamp of the block.                                                                                                                                             | `1742793063000000000`                                                                     |
| `user_address`      | The address on which the row is focused.                                                                                                                                | `CsVdJ8WH8Q9eHSTRpwtwN3TYApm24QnLKYUMNxJ3DaED`                                            |
| `transaction_hash`  | Transaction hash.                                                                                                                                                       | `syJFDzPJJ92GLsXqYXUKEY23e8uoLPAdgci7Ko9cUYZxvCvf5SHdKnYuC1Jh7UrTSzRc2EpUB7kzCwGd2qdTnKD` |
| `transaction_type`  | <p>Event type. <br><br><strong>See more information</strong> <a href="#possible-values-for-the-field-transaction_type"><strong>below</strong></a><strong>.</strong></p> | `transfer`                                                                                |
| `transaction_index` | The index of the transaction.                                                                                                                                           | `15`                                                                                      |
| `ordinal`           | Index of the event.                                                                                                                                                     | `5`                                                                                       |
| `sender_address`    | The address that sends tokens or coins.                                                                                                                                 | `2AXXcN6oN9bBT5owwmTH53C7QHUXvhLeu718Kqt8rvY2`                                            |
| `receiver_address`  | The address that receives tokens or coins.                                                                                                                              | `CsVdJ8WH8Q9eHSTRpwtwN3TYApm24QnLKYUMNxJ3DaED`                                            |
| `token_symbol`      | Symbol of the token or coin transfered                                                                                                                                  | `SOL`                                                                                     |
| `token_address`     | The address of the token or coin transfered.                                                                                                                            | `So11111111111111111111111111111111111111112`                                             |
| `direction`         | Inflow or outflow from the user\_address.                                                                                                                               | `out`                                                                                     |
| `amount`            | Amount of asset transfered.                                                                                                                                             | `3.697694466`                                                                             |
| `amount_usd`        | Amount of asset transferred in usd.                                                                                                                                     | `513.02619`                                                                               |
| `balance_after`     | Wallet balance for the user\_address for this asset.                                                                                                                    | `2816.119373498`                                                                          |
| `balance_after_usd` | Wallet balance for the user\_address for this asset in usd.                                                                                                             | `390714.54077`                                                                            |

### Request example

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed -H "Accept: application/json" -H "X-Api-Key: <client-api-key>" \
  "https://eu.market-api.kaiko.io/v2/data/wallet.v1/audit?blockchain=solana"
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
blockchain = "solana" 

# ---- Optional parameters ---- #
start_time = "2025-03-05T00:00:00Z"
end_time = "2025-03-05T00:02:00Z"
page_size = 100
sort = "desc"
transaction_hash = None
user_address = None
token_address = None

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, blockchain: str, start_time: str, end_time: str, page_size: int, sort: str, transaction_hash: str, user_address: str, token_address: str):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://us.market-api.kaiko.io/v2/data/wallet.v1/audit'
    params = {
        "blockchain": blockchain,
        "start_time": start_time,
        "end_time": end_time,
        "page_size": page_size,
        "sort": sort,
        "transaction_hash": transaction_hash,
        "user_address": user_address,
        "token_address": token_address
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, blockchain=blockchain, start_time=start_time, end_time=end_time, page_size=page_size, sort=sort, transaction_hash=transaction_hash, user_address=user_address, token_address=token_address)
print (df)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Response example

```json
{
  "query":
    {
        "live": "False",
        "start_time": "2024-01-01T00:00:00.000Z",
        "end_time": "2024-01-02T00:00:00.000Z",
        "start_block": 0,
        "end_block": 0,
        "page_size": 100,
        "sort": "0",
        "data_version": "v1",
        "commodity": "wallet_data",
        "request_time": "2024-01-01T00:00:00.000Z"
    },
    "time": "2024-01-01T00:00:00.000Z",
    "timestamp": 1732530743000,
    "access":
    {
        "access_range":
        {
            "start_timestamp": 1073001600000,
            "end_timestamp": "None"
        },
        "data_range":
        {
            "start_timestamp": "None",
            "end_timestamp": "None"
        }
    },
    "data":
    [
    	{
            "chain": "solana",
            "block_number": 328800011,
            "timestamp": 1742793063000000000,
            "user_address": "h3ZXAE168mNxsszYYrUfkMVSCWx6DU2Uvrx97Kb1Nch",
            "transaction_hash": "swSCgiEcupMtZpvuhubRp1h9BXkWdgox11qgJKofNxSnMTQuqAJEGbaiQyJtg5qXxVtyeVzUDizyLvcHcVj7E2k",
            "transaction_type": "transaction_fee",
            "transaction_index": 990,
            "ordinal": 11,
            "sender_address": "h3ZXAE168mNxsszYYrUfkMVSCWx6DU2Uvrx97Kb1Nch",
            "receiver_address": "",
            "token_symbol": "SOL",
            "token_address": "NativeSoL1111111111111111111111111111111111",
            "direction": "out",
            "amount": 5e-06,
            "amount_usd": 0.0006937108995617679,
            "balance_after": 51.445994867,
            "balance_after_usd": 7137.729475607333
        },
        /* ... */
    ],
    "continuation_token": "xxx",
    "next_url": "https://us.market-api.kaiko.io/v2/data/wallet.v1/audit?continuation_token=xxx"
    }
}
```

### **Possible values for the field `transaction_type`:**

<table><thead><tr><th width="397">Value</th><th>Description</th></tr></thead><tbody><tr><td><code>transfer</code></td><td>A coin transfer operation.</td></tr><tr><td><code>token_transfer</code></td><td>This operation involves the transfer of (SPL) tokens.</td></tr><tr><td><code>gas_fees</code></td><td>The amount of gas purchased by the initiator to execute the transaction.</td></tr></tbody></table>

[^1]: Find a full list of token addresses using the reference api.\
    \
    Eg `https://reference-data-api.kaiko.io/v1/assets?code=sol`

[^2]: Find a full list of tokens using the reference api.\
    \
    Eg `https://reference-data-api.kaiko.io/v1/assets`
