# Utility Endpoints

## API Usage

```
GET /v1/api_usage
```

Monitor your consumption against subscription limits.

**Response Fields:**

| Field                                          | Description              |
| ---------------------------------------------- | ------------------------ |
| `plan_name`                                    | Your subscription plan   |
| `limits.api_rows_returned_limit`               | Max rows per month       |
| `limits.api_rows_per_response_limit`           | Max rows per response    |
| `current_period_usage.total_api_rows_returned` | Rows used this month     |
| `current_period_usage.total_requests`          | Requests made this month |

**Example:**

{% tabs %}
{% tab title="Shell" %}

```shell
curl "https://api.gridstatus.io/v1/api_usage?api_key=YOUR_API_KEY"
```

{% endtab %}

{% tab title="Python" %}

```python
usage = client.get_api_usage()
rows_used = usage['current_period_usage']['total_api_rows_returned']
rows_limit = usage['limits']['api_rows_returned_limit']
print(f"Rows used: {rows_used:,} / {rows_limit:,}")
```

{% endtab %}
{% endtabs %}

***

## Dataset Metadata

```
GET /v1/datasets/{dataset_id}
```

Get schema and availability information for a dataset.

**Response Fields:**

| Field                         | Description                          |
| ----------------------------- | ------------------------------------ |
| `id`                          | Dataset identifier                   |
| `name`                        | Human-readable name                  |
| `earliest_available_time_utc` | Start of data availability           |
| `latest_available_time_utc`   | Most recent data timestamp           |
| `time_index_column`           | Primary time column name             |
| `all_columns`                 | List of columns with types           |
| `data_frequency`              | Update interval (e.g., "5\_MINUTES") |

**Example:**

{% tabs %}
{% tab title="Shell" %}

```shell
curl "https://api.gridstatus.io/v1/datasets/ercot_fuel_mix?api_key=YOUR_API_KEY"
```

{% endtab %}

{% tab title="Python" %}

```python
metadata = client.get(
    f"{client.host}/datasets/ercot_fuel_mix",
    return_raw_response_json=True
)
print(f"Available: {metadata['earliest_available_time_utc']} to {metadata['latest_available_time_utc']}")
print(f"Columns: {[col['name'] for col in metadata['all_columns']]}")
```

{% endtab %}
{% endtabs %}

***

## Column Values

```
GET /v1/datasets/{dataset_id}/columns/{column}
```

Get unique values in a column. Useful for discovering filter options.

**Example:**

{% tabs %}
{% tab title="Shell" %}

```shell
curl "https://api.gridstatus.io/v1/datasets/ercot_lmp_by_settlement_point/columns/location?api_key=YOUR_API_KEY"
```

{% endtab %}

{% tab title="Python" %}

```python
result = client.get(
    f"{client.host}/datasets/ercot_lmp_by_settlement_point/columns/location",
    return_raw_response_json=True
)
hubs = [loc for loc in result['unique_values'] if loc.startswith('HB_')]
print(f"Hub locations: {hubs}")
```

{% endtab %}
{% endtabs %}

**Response:**

```json
{
    "column": "location",
    "type": "VARCHAR",
    "unique_values": ["HB_HOUSTON", "HB_NORTH", "HB_SOUTH", "HB_WEST", ...]
}
```

{% hint style="warning" %}
Results are based on the most recent 50,000 rows. Older values may not appear.
{% endhint %}

***

## Dataset Updates

```
GET /v1/dataset-updates/{dataset_id}
```

Track update history to monitor data freshness.

**Query Parameters:**

| Parameter | Default | Description           |
| --------- | ------- | --------------------- |
| `limit`   | None    | Max records to return |
| `order`   | `asc`   | Sort: `asc` or `desc` |

**Example:**

{% tabs %}
{% tab title="Shell" %}

```shell
curl "https://api.gridstatus.io/v1/dataset-updates/ercot_fuel_mix?order=desc&limit=5&api_key=YOUR_API_KEY"
```

{% endtab %}

{% tab title="Python" %}

```python
updates = client.get(
    f"{client.host}/dataset-updates/ercot_fuel_mix",
    params={"order": "desc", "limit": 5},
    return_raw_response_json=True
)
```

{% endtab %}
{% endtabs %}

**Response Fields:**

| Field               | Description                          |
| ------------------- | ------------------------------------ |
| `time_utc`          | When the update occurred             |
| `num_rows_inserted` | New rows added                       |
| `num_rows_updated`  | Existing rows modified               |
| `is_backfill`       | Whether this was historical backfill |

***

## Error Codes

| Code | Description                        |
| ---- | ---------------------------------- |
| 401  | Missing or invalid API key         |
| 403  | Dataset requires paid subscription |
| 404  | Dataset or column not found        |
| 429  | Rate limit exceeded                |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gridstatus.io/developers/concepts/utility-endpoints.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
