Data Export

Download request logs, traces, anomaly snapshots, and security flags as CSV or JSON in one shot. Connect directly to Pandas, Excel, Redash, Metabase, or any other BI tool, or ingest the data on a schedule into your own pipeline.

Endpoints

EndpointData
GET /api/v1/exports/requestsRequest logs — provider, model, tokens, cost, latency, etc.
GET /api/v1/exports/tracesTraces — span count, total cost, duration, etc.
GET /api/v1/exports/anomaliesAnomaly snapshots — daily history of buckets that exceeded 3σ
GET /api/v1/exports/securitySecurity flags — PII detections and prompt injection hits

All endpoints require JWT authentication (authJwt middleware). Include Authorization: Bearer <supabase_access_token> in the request header.

Common query parameters

ParameterDefaultDescription
formatcsvcsv or json
fromISO 8601 start time (e.g. 2026-05-01T00:00:00Z). Defaults to 30 days ago if omitted.
toISO 8601 end time. Defaults to now if omitted.
limit100001–10,000. Maximum 10,000 rows per request. For more data, paginate using from/to.

Additional parameters for requests

Extra filters available only on GET /api/v1/exports/requests.

ParameterDescription
projectIdExport only requests belonging to a specific project.
providerOne of openai / anthropic / gemini.
modelPartial match, case-insensitive (e.g. mini).
providerKeyIdOnly requests that used a specific provider key.
statusok (2xx) / 4xx / 5xx.

File names

The response includes a Content-Disposition header with a date-stamped filename.

EndpointExample filename
/exports/requestsspanlens-requests-2026-05-15.csv
/exports/tracesspanlens-traces-2026-05-15.csv
/exports/anomaliesspanlens-anomalies-2026-05-15.csv
/exports/securityspanlens-security-2026-05-15.csv

CSV columns — requests

ColumnDescription
idUnique request ID
project_idProject this request belongs to
provideropenai / anthropic / gemini
modelDated variant returned by the provider (e.g. gpt-4o-mini-2024-07-18)
prompt_tokensInput token count (gross, including cached portion)
completion_tokensOutput token count
total_tokensprompt + completion
cost_usdCalculated cost in USD. Empty if the model is not in the price table.
latency_msTime from proxy receiving the request to last byte sent (ms)
status_codeHTTP status code returned by the provider
error_messageError string. Empty for successful requests.
trace_idLinked trace ID. Empty if the call was not made inside an SDK observe().
created_atWhen the request arrived at the proxy (ISO 8601 UTC)

CSV columns — traces

ColumnDescription
idUnique trace ID
project_idProject this trace belongs to
nameTrace name (specified in the SDK)
statusok / error
error_messageError string. Empty for successful traces.
duration_msFirst span start to last span end (ms)
total_cost_usdSum of costs across all requests in the trace (USD)
total_tokensSum of tokens across all requests in the trace
span_countNumber of spans in the trace
started_atTrace start time (ISO 8601 UTC)
ended_atTrace end time (ISO 8601 UTC)
created_atWhen the row was saved to the database (ISO 8601 UTC)

curl examples

CSV download

# Request logs — specific date range, GPT-4o only, CSV
curl "https://spanlens-server.vercel.app/api/v1/exports/requests?from=2026-05-01T00:00:00Z&to=2026-05-15T23:59:59Z&provider=openai&model=gpt-4o&format=csv" \
  -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
  -o spanlens-requests.csv

# Traces — last 7 days, JSON
curl "https://spanlens-server.vercel.app/api/v1/exports/traces?from=2026-05-08T00:00:00Z&format=json" \
  -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
  -o spanlens-traces.json

# Anomaly history — defaults (30 days, CSV)
curl "https://spanlens-server.vercel.app/api/v1/exports/anomalies" \
  -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
  -o spanlens-anomalies.csv

# Security flags — from a specific date
curl "https://spanlens-server.vercel.app/api/v1/exports/security?from=2026-05-01T00:00:00Z" \
  -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
  -o spanlens-security.csv
bash

JSON download

curl "https://spanlens-server.vercel.app/api/v1/exports/requests?format=json&limit=1000" \
  -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN"

# Response shape:
# [
#   {
#     "id": "req_xxx",
#     "project_id": "proj_xxx",
#     "provider": "openai",
#     "model": "gpt-4o-mini-2024-07-18",
#     "prompt_tokens": 512,
#     "completion_tokens": 128,
#     "total_tokens": 640,
#     "cost_usd": 0.000096,
#     "latency_ms": 843,
#     "status_code": 200,
#     "error_message": null,
#     "trace_id": null,
#     "created_at": "2026-05-15T09:00:00.000Z"
#   },
#   ...
# ]
bash

BI tool tips

Pandas (Python)

import pandas as pd
import requests, io

token = "YOUR_SUPABASE_ACCESS_TOKEN"
url = "https://spanlens-server.vercel.app/api/v1/exports/requests?from=2026-05-01T00:00:00Z&format=csv"

r = requests.get(url, headers={"Authorization": f"Bearer {token}"})
df = pd.read_csv(io.StringIO(r.text))

# Average cost by model
print(df.groupby("model")["cost_usd"].mean())
python

Excel

Download the .csv file with curl, then import it into Excel via Data → From Text/CSV. The created_at column is an ISO 8601 string — convert it with DATEVALUE + TIMEVALUE or Power Query's date/time type conversion before using it in pivot tables.

Limitations

  • 10,000 row maximum. This is the hard cap per request. For larger datasets, paginate by splitting the time range with from/to.
  • request_body / response_body are not included. Body content is excluded for security and size reasons. View individual request bodies in the /requests detail view or via GET /api/v1/requests/:id.
  • Not real-time. Exports are a point-in-time snapshot. In-flight streaming requests or async logging delays may mean the most recent rows are not yet present.
  • Rate limit. Export endpoints are capped at 10 requests per minute. Space out calls in bulk batch pipelines.

Related: Requests, Traces, Anomalies, Security.