# Checking API usage statistics

> The API Reference is also the SDK and CLI reference. Consecutive code fences marked `tab=HTTP`, `tab=Node`, `tab=Python` and `tab=CLI` are the same call on each surface (a fence marked `tab=HTTP,CLI` is the same text for both), and a block between `:::surface <names>` and `:::` applies only to the surfaces it names. Identifiers in the text are written as in Node and in HTTP JSON (camelCase); the Python SDK spells methods, parameters and result attributes in snake_case (`sendMessage` → `send_message`, `reconnectionLink` → `reconnection_link`), while names inside HTTP JSON stay camelCase.

This page explains how to check Linked API usage statistics. You can use this information to stay within LinkedIn limits for your account.

:::surface node
In the Node SDK this is `linkedapi.getApiUsage()` – the call is below.
:::

:::surface python
In the Python SDK this is `linkedapi.get_api_usage()` – the call is below.
:::

:::surface cli
In the CLI this is `linkedin stats usage` – the command is below.
:::

> In addition to monitoring usage, you can configure action limits for each account on the [platform](https://app.linkedapi.io/). When a limit is reached, actions will automatically return a `limitExceeded` error instead of executing.

We provide statistics as an array of all actions executed during a specific period. To access it, make a `GET` request to the following endpoint with 2 parameters:

```text tab=HTTP
GET https://api.linkedapi.io/stats/actions?start={}&end={}
```

```typescript tab=Node
// Get usage stats for the last 7 days
const endDate = new Date();
const startDate = new Date(endDate.getTime() - 7 * 24 * 60 * 60 * 1000);

const { data } = await linkedapi.getApiUsage({
  start: startDate.toISOString(),
  end: endDate.toISOString()
});
```

```python tab=Python
from datetime import datetime, timedelta, timezone
from linkedapi import ApiUsageParams

# Get usage stats for the last 7 days
end_date = datetime.now(timezone.utc)
start_date = end_date - timedelta(days=7)

result = linkedapi.get_api_usage(
    ApiUsageParams(
        start=start_date.isoformat(),
        end=end_date.isoformat(),
    )
)
```

```bash tab=CLI
linkedin stats usage --start 2024-01-01T00:00:00Z --end 2024-01-31T00:00:00Z --json
```

## Parameters

:::surface node,python
In the SDK this is the `getApiUsage` method; it takes `start` and `end` and returns the array below in `data`.
:::

:::surface cli
In the CLI this is `linkedin stats usage`:

```bash
linkedin stats usage --start <timestamp> --end <timestamp> [flags]
```

| Flag | Type | Required | Description |
| --- | --- | --- | --- |
| `--start` | string | yes | Start date in ISO timestamp |
| `--end` | string | yes | End date in ISO timestamp |
:::

- `start` – timestamp from which the statistics will be retrieved.
- `end` – timestamp up to which the statistics will be retrieved.

> The difference between `start` and `end` must not exceed 30 days.

## Result

:::surface http
In response, you receive an array of actions executed during the specified period:
:::

:::surface node,python
**Result** – `data` is the `result` array below, one item per action executed during the period:
:::

:::surface cli
**Output** – with `--json` or into a pipe, the CLI prints this `result` array as `data`:
:::

```json
{
  "success": true,
  "result": [
    {
      "actionType": "st.openCompanyPage",
      "success": true,
      "time": "2023-01-02T12:30:00Z"
    },
    {
      "actionType": "st.sendMessage",
      "success": false,
      "time": "2023-01-03T12:30:00Z"
    },
    {
      "actionType": "nv.retrieveCompanyEmployees",
      "success": true,
      "time": "2023-01-04T12:30:00Z"
    },
    {
      "actionType": "st.sendConnectionRequest",
      "success": true,
      "time": "2023-01-07T12:30:00Z"
    }
    ...
  ]
}
```

> In case of an unsuccessful request, you'll receive one of the [common errors](/docs/common-errors).
