Skip to main content

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.

const { result, error } = await unprice.analytics.getUsage({
  projectId: "project_1234567890",
  range: "24h",
  customerId: "cus_1234567890" // optional
});

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result);
{
  "usage": [
    {
      "projectId": "project_1234567890",
      "customerId": "cus_1234567890",
      "featureSlug": "feature_1",
      "valueAfter": 30
    }
  ]
}

Request

projectId
string
required
The ID of the project to get usage for
range
string
required
The time range to get usage for (last hour, day, week, month, or 3 months)
customerId
string
The ID of the customer to get usage for (optional)

Response

usage
array
required
Array of usage data points
usage[].projectId
string
required
The ID of the project
usage[].customerId
string
The ID of the customer
usage[].featureSlug
string
required
The slug of the feature
usage[].valueAfter
number
required
The latest value reported for the feature in the selected range