Prompt

How do I track which API endpoints are used most and what they cost?

Technology / API Platforms1 observationLast seen Oct 5, 2026

Latest observation

Oct 5, 2026OpenAI APIWeb search: off

To track which API endpoints are used most and what they cost, you need two things:

  1. Usage data — who called what, when, how often, and with what size/latency/status.
  2. Cost data — the pricing rules that turn usage into dollars.

A practical setup looks like this:

1) Log every API request

Capture at least:

  • timestamp
  • endpoint / route
  • method
  • user_id / api_key / tenant
  • status_code
  • latency_ms
  • request_size
  • response_size
  • region or deployment, if relevant
  • trace_id / request_id

Example log fields:

{
  "timestamp": "2026-10-05T12:34:56Z",
  "endpoint": "/v1/orders",
  "method": "POST",
  "user_id": "u_123",
  "api_key_id": "key_abc",
  "status_code": 200,
  "latency_ms": 143,
  "request_size": 842,
  "response_size": 2048
}

2) Aggregate endpoint usage

Create metrics such as:

  • Requests per endpoint
  • Unique users per endpoint
  • Error rate per endpoint
  • Avg / p95 latency per endpoint
  • Bytes in/out per endpoint

This helps you identify the “most used” endpoints by:

  • total requests
  • total users
  • total traffic
  • total cost

3) Map each endpoint to cost

Costs usually come from one or more of these:

  • Per request cost
  • Per GB transferred
  • Compute time cost
  • Database / downstream calls cost
  • Third-party API calls
  • Inference/token usage if it’s AI-related

You can assign a cost formula per endpoint, for example:

cost(endpoint) = request_count * request_unit_cost
               + data_out_gb * egress_cost_per_gb
               + cpu_seconds * cpu_cost_per_second

If your endpoints have different cost profiles, keep a pricing table like:

EndpointCost per 1k requestsCost per GBNotes
/v1/orders$0.20$0.05DB-heavy
/v1/search$0.10$0.02cacheable
/v1/recommendations$1.50$0.05ML-heavy

4) Use observability tools

Common options:

  • Logs + metrics + traces:

    • OpenTelemetry
    • Prometheus + Grafana
    • Datadog
    • New Relic
    • Splunk
    • ELK/Elastic
  • API gateway analytics:

    • Kong
    • Apigee
    • AWS API Gateway
    • Azure API Management
    • Cloudflare API Gateway

These often provide endpoint-level request counts, latency, and sometimes cost attribution.

5) Build a cost dashboard

Useful dashboard views:

  • Top endpoints by request volume
  • Top endpoints by estimated cost
  • Cost per request by endpoint
  • Cost over time
  • Cost by customer / team / API key
  • Error rate vs cost
  • Latency vs cost

Example query outputs:

  • /v1/search = 1.2M requests, $430 estimated cost
  • /v1/orders = 180k requests, $290 estimated cost
  • /v1/export = 12k requests, $510 estimated cost

That last one is a classic “low volume, high cost” endpoint.

6) If you want chargeback/showback

Track usage by:

  • customer
  • team
  • environment
  • project
  • API key

Then attribute cost to each tenant:

tenant_cost = sum(endpoint_cost for requests made by tenant)

7) Best practices

  • Use a request ID and trace ID to correlate logs, metrics, and downstream costs.
  • Store raw logs in case pricing changes later.
  • Separate estimated cost from actual billed cost.
  • Watch for hidden costs like retries, timeouts, and failed requests.
  • Normalize by endpoint version (/v1, /v2) so you don’t mix old and new behavior.

Simple implementation pattern

  1. Instrument your API server with structured logging.
  2. Export metrics to Prometheus/Datadog.
  3. Maintain a cost mapping table per endpoint.
  4. Run a scheduled job to compute daily endpoint usage and estimated cost.
  5. Publish results in a dashboard.

If you want, I can also give you:

  • a SQL query to calculate endpoint usage and cost,
  • a Python example for logging and cost aggregation, or
  • a Grafana/Datadog dashboard layout.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as Circuit. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.