Skip to content

Account & billing

Query history

Base URL

https://api.ppq.ai

GET /queries/history

Retrieve your account's query history.

Authenticate in one of three ways:

  • Your API key as Authorization: Bearer <api_key>.
  • Your API key in the api-key header.
  • Your credit ID in the credit_id query parameter.

With an API key, results only include queries made with that key. Pass all_keys=true to see every query on the account.

Query parameters

ParameterTypeRequiredDescription
credit_id
string
No
Authenticate as the full account instead of with an API key.
all_keys
boolean
No
true includes queries from all API keys. Only valid when you authenticate with an API key.
api_key
string
No
Only return queries made with this API key (the full key string). Only valid when you authenticate with credit_id.
start_date
string (ISO 8601)
No
Return queries on or after this date.
end_date
string (ISO 8601)
No
Return queries on or before this date.
model
string
No
Filter by model name.
query_source
string
No
Filter by query source.
query_type
string
No
Filter by query type.
page
integer
No
Page number. Default: 1.
page_count
integer
No
Results per page, up to 100. Default: 20.

Response

The response has status ("success"), a data array and pagination (page, page_count, total, total_pages). Each record in data has timestamp (ISO 8601), model, input_count and output_count (tokens), price_in_usd, query_type, query_source, api_key_id and isFreeModel, plus:

FieldDescription
isOnline
Whether the query used online mode (web search).
status
"error" on a failed query. Absent when the query succeeded.
error_code
Failed queries only. One of upstream_error, upstream_unreachable, stream_failed, transform_failed, timeout, invalid_request, model_unavailable, insufficient_balance, free_model_unauthorized, generation_failed, internal_error.
http_status
Failed queries only. HTTP status of the failure (integer), or null when there was none.

Failed queries are listed in time order alongside successful ones. Their price_in_usd is what was actually charged, or 0 when nothing was billed.

Example

import requests

api_key = "YOUR_API_KEY"
url = "https://api.ppq.ai/queries/history"

headers = {
    "Authorization": f"Bearer {api_key}"
}

# Optional filters: start_date, end_date, model, query_source, query_type, page, page_count, all_keys
params = {
    "page": 1,
    "page_count": 20
}

response = requests.get(url, headers=headers, params=params)
print(response.json())