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

# Analytics API

> Export analytics data for GPU operators

# Analytics API

The Analytics API allows GPU operators to export analytics data for a given time range. This API provides detailed insights into your GPU operations, including performance metrics, usage statistics, and other operational data.

## Authentication

All API requests require authentication using a Bearer token. You can generate an API key from the [Inference.net Dashboard](https://inference.net/dashboard) under the API Keys page.

<Note>
  Include your API token in the `Authorization` header of all requests: `  Authorization: Bearer YOUR_API_TOKEN`
</Note>

## Base URL

```
https://relay.inference.net/api/v1
```

## Interactive API Documentation

You can explore and test the Analytics API using our interactive Swagger documentation:

<Card title="Swagger API Documentation" icon="code" href="https://relay.inference.net/api/v1/docs">
  Interactive API documentation with a live testing interface
</Card>

## Endpoints

### Export Operator Analytics

Export analytics data for your GPU operations within a specified time range.

#### Endpoint

```
POST /operator/analytics
```

#### Request

**Headers**

```json theme={"system"}
{
  "Authorization": "Bearer YOUR_API_TOKEN",
  "Content-Type": "application/json"
}
```

**Request Body**

<Tip>
  The maximum time range for a single request is 15 days. Please limit requests
  to 1-3 days for best results.
</Tip>

```json theme={"system"}
{
  "startDate": "2024-01-01T00:00:00Z",
  "endDate": "2024-01-31T23:59:59Z"
}
```

**Parameters**

| Parameter   | Type   | Required | Description                                           |
| ----------- | ------ | -------- | ----------------------------------------------------- |
| `startDate` | string | Yes      | Start date for the analytics period (ISO 8601 format) |
| `endDate`   | string | Yes      | End date for the analytics period (ISO 8601 format)   |

<Info>
  All date fields must be provided in ISO 8601 format (e.g.,
  `2024-01-15T10:30:00Z`)
</Info>

#### Response

**Success Response (200 OK)**

The response will contain your operator analytics data for the specified time range. The exact structure of the response will include:

* Performance metrics
* Usage statistics
* GPU utilization data
* Request/response metrics
* Revenue and earnings data (if applicable)

```json theme={"system"}
{
  "status": 200,
  "data": {
    // Analytics data structure
  }
}
```

**Error Responses**

| Status Code | Description                                                                                     |
| ----------- | ----------------------------------------------------------------------------------------------- |
| 400         | Invalid request parameters - Check your date format and ensure all required fields are provided |
| 401         | Unauthorized - Invalid or missing API token                                                     |
| 403         | Forbidden - You don't have permission to access this resource                                   |
| 500         | Internal server error - Please try again later or contact support                               |

## Code Examples

### cURL

```bash theme={"system"}
curl -X POST https://relay.inference.net/api/v1/operator/analytics \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "startDate": "2024-01-01T00:00:00Z",
    "endDate": "2024-01-31T23:59:59Z"
  }'
```

### JavaScript/TypeScript

```typescript theme={"system"}
const response = await fetch(
  "https://relay.inference.net/api/v1/operator/analytics",
  {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_API_TOKEN",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      startDate: "2024-01-01T00:00:00Z",
      endDate: "2024-01-31T23:59:59Z",
    }),
  }
);

const analytics = await response.json();
console.log(analytics);
```

### Python

```python theme={"system"}
import requests
import json
from datetime import datetime

url = "https://relay.inference.net/api/v1/operator/analytics"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}

data = {
    "startDate": "2024-01-01T00:00:00Z",
    "endDate": "2024-01-31T23:59:59Z"
}

response = requests.post(url, headers=headers, json=data)
analytics = response.json()
print(analytics)
```

## Date Format Guidelines

The Analytics API uses ISO 8601 date format for all date/time parameters. This ensures consistent handling of dates across different time zones.

### Format Pattern

```
YYYY-MM-DDTHH:MM:SSZ
```

### Examples

* `2024-01-15T00:00:00Z` - January 15, 2024 at midnight UTC
* `2024-03-20T14:30:00Z` - March 20, 2024 at 2:30 PM UTC
* `2024-12-31T23:59:59Z` - December 31, 2024 at 11:59:59 PM UTC

<Tip>
  For the best results, we recommend only querying short time ranges (e.g. 1
  day, 3 days) in each request.
</Tip>

## Getting Your API Key

To use the Analytics API, you'll need an API key:

1. Log in to the [Inference.net Dashboard](https://inference.net/dashboard)
2. Navigate to the **API Keys** section
3. Click **Generate New API Key**
4. Copy your API key and store it securely

## Support

If you encounter any issues or have questions about the Analytics API:

* Email: [support@inference.net](mailto:support@inference.net)
* Check our [Swagger documentation](https://relay.inference.net/api/v1/docs) for interactive API testing
* Visit the [Inference.net Dashboard](https://inference.net/dashboard) for account management
