Skip to content

Log Query & Export

Query API call logs for your account — useful for usage tracking, billing verification and troubleshooting.

Endpoint

  • Method: GET
  • URL: https://1688token.ai/api/log/self
  • Auth: Bearer Token

Query Parameters

ParameterTypeRequiredDescription
pintegerPage number. Default: 1
page_sizeintegerItems per page. Default: 10, max 100
start_timestampintegerStart time (Unix timestamp in milliseconds)
end_timestampintegerEnd time (Unix timestamp in milliseconds)
model_namestringFilter by model name
typeintegerLog type: 1 top-up, 2 usage, 0 all

Request Examples

python
import requests
import time

api_key = "YOUR_API_KEY"
base_url = "https://1688token.ai"

# Query usage logs for the past 7 days
now = int(time.time() * 1000)
seven_days_ago = now - 7 * 24 * 60 * 60 * 1000

resp = requests.get(
    f"{base_url}/api/log/self",
    headers={"Authorization": f"Bearer {api_key}"},
    params={
        "p": 1,
        "page_size": 20,
        "start_timestamp": seven_days_ago,
        "end_timestamp": now,
        "type": 2
    }
)

data = resp.json()
for log in data["data"]["items"]:
    print(f"{log['model_name']} | {log['prompt_tokens']}+{log['completion_tokens']} tokens | quota: {log['quota']}")
javascript
const apiKey = "YOUR_API_KEY";
const baseURL = "https://1688token.ai";

const now = Date.now();
const sevenDaysAgo = now - 7 * 24 * 60 * 60 * 1000;

const params = new URLSearchParams({
  p: 1,
  page_size: 20,
  start_timestamp: sevenDaysAgo,
  end_timestamp: now,
  type: 2
});

const resp = await fetch(`${baseURL}/api/log/self?${params}`, {
  headers: { Authorization: `Bearer ${apiKey}` }
});

const data = await resp.json();
data.data.items.forEach(log => {
  console.log(`${log.model_name} | ${log.prompt_tokens}+${log.completion_tokens} tokens`);
});
bash
curl "https://1688token.ai/api/log/self?p=1&page_size=20&type=2" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response Example

json
{
  "success": true,
  "data": {
    "items": [
      {
        "id": 12345,
        "created_at": 1715000000,
        "model_name": "claude-sonnet-4-6",
        "type": 2,
        "prompt_tokens": 120,
        "completion_tokens": 85,
        "quota": 500,
        "content": "Explain large language models..."
      }
    ],
    "total": 100
  }
}

Response Fields

FieldTypeDescription
idintegerLog entry ID
created_atintegerRequest time (Unix timestamp)
model_namestringModel used
typeinteger1 top-up, 2 usage
prompt_tokensintegerInput token count
completion_tokensintegerOutput token count
quotaintegerQuota consumed
contentstringRequest content summary

Usage Statistics

Query aggregated daily stats:

bash
curl "https://1688token.ai/api/log/stat?start_timestamp=1714320000000&end_timestamp=1715000000000" \
  -H "Authorization: Bearer YOUR_API_KEY"