# Distribution of the catalog

`GET https://api.handlesapi.com/v1/directory/{platform}/facets`

The GET /v1/directory/{platform}/facets endpoint of Handles API (Directory): Distribution of the catalog. One call costs 1 credit (a catalog read) and needs the `directory:read` scope. A success returns JSON as `{ data, meta }`.

How the addressable catalog splits across language, country, category and audience band. X language and country come from an exact hourly rollup; every other axis is estimated from a block sample and labelled as such.

- APPROXIMATE BY DESIGN. Every axis marked method: sample is a scaled block sample, not a count. An exact count(*) group by over an 18M-row catalog reads the whole table and blows the query timeout - this is the same reason the directory filter chips are precomputed rather than counted per request.
- Block sampling reads whole pages, so values that cluster by insertion order carry more noise than their share suggests. Treat small buckets as directional and large ones as reliable.
- X language and country are exact: the engine writes them into xdir_facets hourly.
- An axis that cannot be produced inside the query budget is returned as available: false with a reason, never as a slow scan or a silent zero.
- Facets always describe the addressable scope (active, non-NSFW, handled).

## Request

```bash
curl "https://api.handlesapi.com/v1/directory/x/facets" \
  -H "Authorization: Bearer $HANDLES_API_KEY"
```

`HANDLES_API_KEY` is a key from your dashboard; send it as `Authorization: Bearer` or `x-api-key`.

## Parameters

- `platform` (path, enum, required): Which catalog to read. (values: x, telegram, bluesky, youtube, tiktok, instagram, kick, twitch; example: x)
- `axes` (query, enum, optional): Comma-separated axes to compute. Defaults to all four. (values: language, country, category, followers; example: language,followers)

## Response

```json
{
  "data": {
    "platform": "x",
    "scope": "addressable",
    "estimated_rows": 18312640,
    "facets": {
      "language": {
        "available": true,
        "method": "rollup",
        "approximate": false,
        "values": [
          {
            "value": "en",
            "count": 7402118
          },
          {
            "value": "tr",
            "count": 242483
          }
        ]
      },
      "followers": {
        "available": true,
        "method": "sample",
        "approximate": true,
        "sampled_rows": 8904,
        "values": [
          {
            "value": "0-1k",
            "count": 11204882,
            "sampled": 5449
          },
          {
            "value": "1k-10k",
            "count": 4918330,
            "sampled": 2392
          }
        ]
      },
      "country": {
        "available": false,
        "reason": "tiktok has no 'country' in the catalog."
      }
    }
  },
  "meta": {
    "request_id": "req_9f2c41a8b3d5",
    "generated_at": "2026-08-23T09:14:02.317Z",
    "took_ms": 42
  }
}
```

## Errors

- 401 unauthorized: No key was sent, or the key is unknown or revoked.
- 402 quota_exceeded: Your plan's credits for this period are used up and overage is off (or its cap is reached). Waiting does not help: upgrade, or turn on overage in the dashboard.
- 404 not_found: The addressed resource does not exist.
- 422 invalid_request: A parameter is malformed, out of range or mutually exclusive with another. details names the offending fields.
- 429 rate_limited, live_limit_reached: Too many requests. rate_limited clears when the minute window resets (see Retry-After); live_limit_reached (Free plan) clears at 00:00 UTC.
- 500 internal_error: Something failed on our side. The call was not charged; quote the request_id to support.
- 503 upstream_timeout, upstream_error, platform_unavailable, service_unavailable: The call could not be served right now and was not charged. upstream_timeout / upstream_error: a data source was slow or failed, retry with backoff. platform_unavailable: live reads for that platform are paused. service_unavailable: retry shortly.

Failures use the error envelope `{ error: { code, message, request_id } }`: https://handlesapi.com/docs/errors

Source: https://handlesapi.com/docs/reference/directory-facets
