GET
/
api
/
users
import requests
from urllib.parse import urlencode


base_url = "https://api.keywordsai.co/api/users/"
api_key = production_api_key # Replace with your actual Keywords AI API key
get_params = {
    'page_size': 10,
    'summary_type': 'all',
    'date': '2024-03-09 00:00:00'
}
headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json"
}

# Convert the params into url encoded string
params = urlencode(get_params)
url = f"{base_url}?{params}"
response = requests.get(url, headers=headers)
print(response.json())
{
  "results": [
      {
        "id": 00001,
        "organization_name": "xxx",
        "email": "",
        "name": "",
        "customer_identifier": "sample-user-id",
        "active_days": 1,
        "last_active_timeframe": "2024-06-07 17:35:34.452434+00:00",
        "requests": 1,
        "total_requests": 1,
        "tokens": 33,
        "total_tokens": 33,
        "cost": 5.2e-05,
        "total_cost": 5.2e-05,
        "average_sentiment": null,
        "active_duration": "00:00:00",
        "first_seen": "2024-06-07T17:35:34.491504Z",
        "top_models": {
            "gpt-3.5-turbo": 1
        },
        "cache_hits": 0,
        "average_latency": 0.0,
        "average_ttft": 0.0,
        "total_prompt_tokens": 8,
        "total_completion_tokens": 25,
        "average_monthly_cost": 0.00156,
        "total_budget": null,
        "period_budget": null
      }
  ],
    "count": 1,
    "previous": null,
    "next": null,
    "aggregation_data": {}
}
Make sure you add Api-Key prefix to your token

You can paste the command below into your terminal to run your first API request. Make sure to replace YOUR_KEYWORDSAI_API_KEY with your actual Keywords AI API key.

date
string
default:"current time"

Date string in ISO format. Combined with summary_type, this will retrieve data from the time frame that contains this date.

summary_type
string

The range of data to retrieve. Possible values: all, daily, weekly, monthly, and yearly.

Example: summary_type=weekly, date=2024-03-09 00:00:00 will retrieve data for the week that contains 2024-03-09 00:00:00.

timezone_offset
int
default:0

The timezone offset in hours is defined as UTC - local time. This helps you calibrate the date timeframe of your data.

Example: PST time is -8 hours from UTC, so the timezone_offset is 8.

Response params:

import requests
from urllib.parse import urlencode


base_url = "https://api.keywordsai.co/api/users/"
api_key = production_api_key # Replace with your actual Keywords AI API key
get_params = {
    'page_size': 10,
    'summary_type': 'all',
    'date': '2024-03-09 00:00:00'
}
headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json"
}

# Convert the params into url encoded string
params = urlencode(get_params)
url = f"{base_url}?{params}"
response = requests.get(url, headers=headers)
print(response.json())
{
  "results": [
      {
        "id": 00001,
        "organization_name": "xxx",
        "email": "",
        "name": "",
        "customer_identifier": "sample-user-id",
        "active_days": 1,
        "last_active_timeframe": "2024-06-07 17:35:34.452434+00:00",
        "requests": 1,
        "total_requests": 1,
        "tokens": 33,
        "total_tokens": 33,
        "cost": 5.2e-05,
        "total_cost": 5.2e-05,
        "average_sentiment": null,
        "active_duration": "00:00:00",
        "first_seen": "2024-06-07T17:35:34.491504Z",
        "top_models": {
            "gpt-3.5-turbo": 1
        },
        "cache_hits": 0,
        "average_latency": 0.0,
        "average_ttft": 0.0,
        "total_prompt_tokens": 8,
        "total_completion_tokens": 25,
        "average_monthly_cost": 0.00156,
        "total_budget": null,
        "period_budget": null
      }
  ],
    "count": 1,
    "previous": null,
    "next": null,
    "aggregation_data": {}
}