# Get Portfolio Valuation

<mark style="color:green;">**`GET`**</mark> `https://api.sfox.com/v1/account/balance/history`

Retrieve a history of the USD value of your account's portfolio at hourly or daily intervals

## Request

### Query Parameters

<table><thead><tr><th width="136.453125">Name</th><th width="115.68359375" align="center">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>start_date</code> <em><mark style="color:red;">required</mark></em></td><td align="center">timestamp</td><td>Timestamp of the start of the query. Unix timestamp (ms)</td></tr><tr><td><code>end_date</code></td><td align="center">timestamp</td><td>Timestamp of the end of the query. Unix timestamp (ms)</td></tr><tr><td><code>interval</code></td><td align="center">int</td><td><p>Timeseries interval (sec). <br>Possible values: <code>3600</code> (hourly), <code>86400</code> (daily)</p><p>Default value: <code>86400</code></p></td></tr></tbody></table>

### Example Request

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

```bash
curl -H 'Authorization: Bearer <API_TOKEN>'
'https://api.sfox.com/v1/account/balance/history?interval=86400&start_date=1701475200000&end_date=1701734400000'
```

{% endcode %}
{% endtab %}

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

```javascript
const axios = require('axios');

axios({
  method: 'get',
  url: 'https://api.sfox.com/v1/account/balance/history?interval=86400&start_date=1701475200000&end_date=1701734400000',
  headers: {
    'Authorization': 'Bearer <API_KEY>'
  }
}).then(response => {
  console.log(response)
}).catch(err => {
  console.error(err)
});
```

{% endcode %}
{% endtab %}

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

```python
import requests

data = requests.get(
  "https://api.sfox.com/v1/account/balance/history?interval=86400&start_date=1701475200000&end_date=1701734400000",
  headers={
    "Authorization": "Bearer <API_KEY>",
  }
)
print(data)
```

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

## Response

### Response Body

<table><thead><tr><th width="156">Key</th><th width="113.375" align="center">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>data</code></td><td align="center">[object]</td><td>An array of portfolio value objects, each object with a <code>timestamp</code> and <code>usd_value</code></td></tr><tr><td><code>timestamp</code></td><td align="center">timestamp</td><td>Unix timestamp (ms) of the valuation</td></tr><tr><td><code>usd_value</code></td><td align="center">number</td><td>USD valuation of your portfolio as of the timestamp</td></tr></tbody></table>

### Responses

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "data": [
        {
            "timestamp": 1701475200000,
            "usd_value": 349515.64495392627
        },
        {
            "timestamp": 1701561600000,
            "usd_value": 349628.6458040236
        },
        {
            "timestamp": 1701648000000,
            "usd_value": 349653.452981625
        },
        {
            "timestamp": 1701734400000,
            "usd_value": 349301.02066800353
        },
        {
            "timestamp": 1701820800000,
            "usd_value": 350066.51819476683
        },
        {
            "timestamp": 1701907200000,
            "usd_value": 350761.96052562393
        }
    ]
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity Invalid Request" %}

```json
//Invalid start_date
{
    "error": "start_date must be a valid unix timestamp in milliseconds"
}

//Invalid end_date
{
    "error": "end_date must be a valid unix timestamp in milliseconds"
}

// Invalid interval
{
    "error": "interval must be 3600 or 86400"
}
```

{% endtab %}
{% endtabs %}
