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

# Get usage analytics

> Get usage analytics for a project or customer

<RequestExample>
  ```ts theme={null}
  const { result, error } = await unprice.analytics.usage.get({
    range: "24h",
    customer_id: "cus_1234567890"
  });

  if (error) {
    console.error(error.message);
    return;
  }

  console.log(result);
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "usage": [
      {
        "project_id": "project_1234567890",
        "customer_id": "cus_1234567890",
        "feature_slug": "ai-messages",
        "usage": 30,
        "spending": {
          "amount": "0.0003",
          "currency": "USD",
          "display_amount": "$0"
        }
      }
    ]
  }
  ```
</ResponseExample>

## Request

<ParamField body="range" type="string" required>
  The usage window to inspect. Supported values include `24h`, `7d`, `30d`, and `90d`.
</ParamField>

<ParamField body="customer_id" type="string">
  Optional customer ID to filter usage.
</ParamField>

<ParamField body="project_id" type="string">
  Optional project ID. Only main-project keys can request another project.
</ParamField>

## Response

<ResponseField name="usage" type="array" required>
  Usage data points for the selected range.
</ResponseField>
