# Platform API

Dwellir exposes two distinct API layers:

- **Blockchain RPC endpoints** (`https://api-{network}.n.dwellir.com`): Query chain state, submit transactions, and stream blocks. Authenticated with an [RPC API key](https://www.dwellir.com/docs/getting-started/authentication).
- **Platform API** (`https://dashboard.dwellir.com/marly-api`): Query usage history by chain and RPC method, inspect error logs, manage API keys, and configure IP whitelists. Authenticated with a scoped, revocable **CLI token**.

The [Dwellir CLI](https://www.dwellir.com/docs/cli) is a thin client over this Platform API. You can call the CLI in terminals and coding agents, or call the underlying HTTP endpoints directly with the same Bearer token.

## CLI vs direct HTTP

| Workflow                                                                                            | Recommended interface                                      |
| --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| Interactive local development, AI coding agents, quick `.env` setup                                 | [Dwellir CLI](https://www.dwellir.com/docs/cli) (`dwellir`)                       |
| Scheduled usage polling, billing attribution pipelines, serverless jobs without installing a binary | [Platform API Reference](https://www.dwellir.com/docs/cli/platform-api) over HTTP |
| CI/CD key provisioning and rotation                                                                 | Either the CLI or direct HTTP calls                        |

## Quickstart

### 1. Create a scoped CLI token

1. Sign in to [dashboard.dwellir.com](https://dashboard.dwellir.com).
2. Open [API keys > CLI tokens](https://dashboard.dwellir.com/api-keys?tab=cli-tokens).
3. Click **Create token**, pick `read` for usage and log polling (or `read-write` for key and whitelist management), and store the value securely.

If you already use the CLI, run `dwellir auth login` once and read the active token with `dwellir auth token`.

```bash
export DWELLIR_TOKEN="<YOUR_CLI_TOKEN>"
```

### 2. Query current billing-cycle usage

```bash
curl -sS https://dashboard.dwellir.com/marly-api/v4/organization/analytics/monthly_summary \
  -H "Authorization: Bearer ${DWELLIR_TOKEN}" \
  -H "Accept: application/json"
```

### 3. Pull daily usage by chain and RPC method

```bash
curl -sS -X POST https://dashboard.dwellir.com/marly-api/v4/organization/analytics \
  -H "Authorization: Bearer ${DWELLIR_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "interval": "day",
    "start_time": "2026-04-01T00:00:00Z",
    "end_time": "2026-04-08T00:00:00Z",
    "limit": 1000,
    "offset": 0
  }'
```

Each row includes `start_time`, `domain` (endpoint hostname for the chain), `method` (RPC method), `requests`, `responses`, `api_key`, and `api_key_name`. Check the `X-Analytics-Has-More` and `X-Analytics-Max-Timestamp` response headers for pagination and incremental polling.

## What you can automate

- **Usage analytics**: Billing-cycle summary, time-bucketed usage by chain/method/key, average and peak RPS, and rate-limited counts.
- **Error logs**: Cursor-paginated error logs, status-code totals, and multi-dimension error facets.
- **API keys**: List, create, update quotas, enable/disable, rotate, and delete RPC API keys.
- **IP whitelists**: Create and update IP allowlists, assign them to keys, and inspect observed request source IPs.
- **Endpoints and account**: Fetch the supported chain/endpoint catalog and organization subscription limits.

## Next steps

- [Platform API Reference](https://www.dwellir.com/docs/cli/platform-api) for every endpoint path, request body, response schema, scope, and error code
- [Dwellir CLI](https://www.dwellir.com/docs/cli) to run the same workflows from your terminal with `--json` or `--toon` output
- [CLI Authentication](https://www.dwellir.com/docs/cli/authentication) for token resolution, profiles, and CI setup
