> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hologram.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get data usage by IMEI through the REST API

> Look up a device by IMEI, then fetch usage via REST API with a Python example.

<Warning>
  **Caution:** IMEIs can change if a SIM moves between devices. Not every network provides IMEI information for every session.
</Warning>

## How do I use the REST API to check usage by IMEI?

<Steps>
  <Step title="Get the device ID from IMEI">
    ```bash cURL theme={null}
    curl --request GET \
      'https://dashboard.hologram.io/api/1/devices/?orgid=YOUR_ORG_ID&imei=YOUR_IMEI' \
      -u apikey:YOUR_HOLOGRAM_API_KEY
    ```
  </Step>

  <Step title="Fetch usage (optionally filter by epoch start/end)">
    ```bash cURL theme={null}
    curl --request GET \
      'https://dashboard.hologram.io/api/1/usage/data?deviceid=YOUR_DEVICE_ID&timestart=YOUR_EPOCH_START&timeend=YOUR_EPOCH_END' \
      -u apikey:YOUR_HOLOGRAM_API_KEY
    ```
  </Step>
</Steps>

## Python example

```python theme={null}
import requests
from requests.auth import HTTPBasicAuth
import json
import datetime

usr = 'apikey'
pwd = 'YOUR_HOLOGRAM_API_KEY'
orgid = 'YOUR_ORG_ID'
imei = 'YOUR_IMEI'

dev_res = requests.get(
  f'https://dashboard.hologram.io/api/1/devices/?orgid={orgid}&imei={imei}',
  auth=HTTPBasicAuth(usr, pwd)
)
device_id = dev_res.json()['data'][0]['id']

start = int(datetime.datetime(2021, 9, 28).timestamp())
end = int(datetime.datetime(2021, 10, 5).timestamp())

usage_res = requests.get(
  f'https://dashboard.hologram.io/api/1/usage/data?deviceid={device_id}&orgid={orgid}&timestart={start}&timeend={end}',
  auth=HTTPBasicAuth(usr, pwd)
)
print(json.dumps(usage_res.json(), indent=2))
```

## Related actions

<Card title="Check data usage in your dashboard" href="/dashboard/usage/usage-single-sim" horizontal>
  Search for a SIM by IMEI then check data usage in your dashboard.
</Card>
