# API Quickstart

[Web version](https://docs.eis.it/en/api/quickstart)

This guide uses `GET /v1/circuits/stats/count` as first authenticated request.

### Get your credentials

Generate the API key in Hive under **User profile &gt; API Keys**. You will receive a `clientId` and a `clientSecret`.

### Get an access token

```bash
curl --request POST \
  --url "https://api.eis.it/auth/api-key/login" \
  --header "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "clientId=$EIS_CLIENT_ID" \
  --data-urlencode "clientSecret=$EIS_CLIENT_SECRET"
```

Read the `access_token` field in the JSON response.

### Send an authenticated request

```bash
curl --request GET \
  --url "https://api.eis.it/v1/circuits/stats/count" \
  --header "Authorization: Bearer $EIS_ACCESS_TOKEN" \
  --header "Accept: application/json"
```

The `200` response contains circuit counts:

```json
{
  "active": 128,
  "ko": 2,
  "delivering": 11
}
```

## JavaScript

```javascript
const response = await fetch("https://api.eis.it/v1/circuits/stats/count", {
  headers: {
    Accept: "application/json",
    Authorization: `Bearer ${process.env.EIS_ACCESS_TOKEN}`,
  },
});

if (!response.ok) {
  throw new Error(`Hive API: HTTP ${response.status}`);
}

console.log(await response.json());
```

## Python

```python
import os
import requests

response = requests.get(
    "https://api.eis.it/v1/circuits/stats/count",
    headers={
        "Accept": "application/json",
        "Authorization": f"Bearer {os.environ['EIS_ACCESS_TOKEN']}",
    },
    timeout=30,
)
response.raise_for_status()
print(response.json())
```

For the parameters and answers of other endpoints consult the [complete reference](/en/api/reference).
