List top

Returns the caller org's ranked lenses for one window, five of them at once.

GET /v1/event/top

Addresshttps://api.hanzo.ai/v1/event/top
MethodGET
Operationget_event_top
AuthAuthorization: Bearer $HANZO_API_KEY

Returns the caller org's ranked lenses for one window, five of them at once. models ranks LLM models by spend and is always real; products ranks commerce orders by revenue; topPages ranks requested paths, topReferrers the external referrer domains ("(direct)" for a missing or same-origin one) and topSources the utm_source campaigns ("(none)" when absent), each by pageviews. Every lens carries each row's share of the in-window total, so a top-N honestly shows the long tail.

The four event lenses report available=false rather than fabricating zeros when the product-event table holds nothing yet. The org is the validated principal's — never a parameter. 401 without a validated bearer, 400 on an unknown range, 503 when the warehouse is unreachable.

Request

4 fields.

FieldInTypeRequiredDescription
rangequerystring—Range is a relative window: a count and a unit — 24h, 7d, 90d, any <N>h or <N>d — or day, week, month, all.
startquerystring—Start is the inclusive lower bound of a custom window, RFC3339.
endquerystring—End is the exclusive upper bound of a custom window, RFC3339.
limitqueryinteger—Limit bounds every ranked lens in the response.

Response

StatusBodyMeaning
200event.Topok
defaultproblem-detailsrefused

200 body — 51 fields.

FieldInTypeAlwaysDescription
endbodystring—End is the window's exclusive upper bound, RFC3339 UTC.
modelsbodyevent.TopModels—
models.availablebodyboolean—Available is true whenever the ledger answered, including with no rows.
models.itemsbodyevent.ModelRow[]—Items is the ranked models, highest spend first.
models.items[].modelbodystring—Model is the model id, e.g. zen5-coder.
models.items[].pctbodynumber (double)—Pct is this model's share of the window's returned spend, 0..100, one decimal.
models.items[].providerbodystring—Provider is who served it.
models.items[].requestsbodyinteger (int64)—Requests is how many calls went to this model.
models.items[].spendCentsbodyinteger (int64)—SpendCents is what they cost, in cents.
models.items[].tokensbodyinteger (int64)—Tokens is prompt plus completion tokens over those calls.
models.sourcebodystring—Source is the warehouse table the lens read.
productsbodyevent.TopProducts—
products.availablebodyboolean—Available is false when the product-event table could not be read.
products.itemsbodyevent.ProductRow[]—Items is the ranked products, highest revenue first.
products.items[].ordersbodyinteger (int64)—Orders is how many order_completed events carried it.
products.items[].productIdbodystring—ProductID is the product the order events named.
products.items[].revenuebodynumber (double)—Revenue is the total they carried, in the events' own currency unit.
products.items[].unitsbodyinteger (int64)—Units is the summed quantity sold.
products.reasonbodystring—Reason says why the lens is unavailable.
products.sourcebodystring—Source is the warehouse table the lens read.
rangebodystring—Range is the window that was actually applied: 24h, 7d, 30d or custom.
scopebodyevent.Scope—
scope.orgbodystring—Org is the IAM org slug the rows were read under: the validated principal's, resolved server-side.
startbodystring—Start is the window's inclusive lower bound, RFC3339 UTC.
topPagesbodyevent.Breakdown—
topPages.availablebodyboolean—Available is false when the product-event table could not be read.
topPages.itemsbodyevent.BreakdownRow[]—Items is the ranked buckets, most pageviews first.
topPages.items[].keybodystring—Key is the bucket: a requested path, a referrer domain ("(direct)" for none or a same-origin one), or a utm_source ("(none)" when absent).
topPages.items[].pageviewsbodyinteger (int64)—Pageviews is how many $pageview events fell in this bucket.
topPages.items[].pctbodynumber (double)—Pct is this bucket's share of ALL in-window pageviews, 0..100, one decimal — not of the returned rows, so a top-N shows the long tail honestly.
topPages.items[].visitorsbodyinteger (int64)—Visitors is how many distinct people they came from.
topPages.reasonbodystring—Reason says why the lens is unavailable.
topPages.sourcebodystring—Source is the warehouse table the lens read.
topReferrersbodyevent.Breakdown—
topReferrers.availablebodyboolean—Available is false when the product-event table could not be read.
topReferrers.itemsbodyevent.BreakdownRow[]—Items is the ranked buckets, most pageviews first.
topReferrers.items[].keybodystring—Key is the bucket: a requested path, a referrer domain ("(direct)" for none or a same-origin one), or a utm_source ("(none)" when absent).
topReferrers.items[].pageviewsbodyinteger (int64)—Pageviews is how many $pageview events fell in this bucket.
topReferrers.items[].pctbodynumber (double)—Pct is this bucket's share of ALL in-window pageviews, 0..100, one decimal — not of the returned rows, so a top-N shows the long tail honestly.
topReferrers.items[].visitorsbodyinteger (int64)—Visitors is how many distinct people they came from.
topReferrers.reasonbodystring—Reason says why the lens is unavailable.
topReferrers.sourcebodystring—Source is the warehouse table the lens read.
topSourcesbodyevent.Breakdown—
topSources.availablebodyboolean—Available is false when the product-event table could not be read.
topSources.itemsbodyevent.BreakdownRow[]—Items is the ranked buckets, most pageviews first.
topSources.items[].keybodystring—Key is the bucket: a requested path, a referrer domain ("(direct)" for none or a same-origin one), or a utm_source ("(none)" when absent).
topSources.items[].pageviewsbodyinteger (int64)—Pageviews is how many $pageview events fell in this bucket.
topSources.items[].pctbodynumber (double)—Pct is this bucket's share of ALL in-window pageviews, 0..100, one decimal — not of the returned rows, so a top-N shows the long tail honestly.
topSources.items[].visitorsbodyinteger (int64)—Visitors is how many distinct people they came from.
topSources.reasonbodystring—Reason says why the lens is unavailable.
topSources.sourcebodystring—Source is the warehouse table the lens read.

Failure carries the platform error shape — see Errors.

Examples

hanzo event top
import { Configuration, EventApi } from 'hanzoai';

const api = new EventApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getEventTop();
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import EventApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = EventApi(client).get_event_top()
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.EventAPI.GetEventTop(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, event_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = event_api::get_event_top(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.EventApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new EventApi(client).getEventTop();
curl https://api.hanzo.ai/v1/event/top \
  -H "Authorization: Bearer $HANZO_API_KEY"

Tool event, op get_event_top — POST the JSON-RPC envelope to https://api.hanzo.ai/v1/mcp.

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "event",
         "arguments": {
           "op": "get_event_top",
           "input": {}
         }
       }
     }'

Event API · All Hanzo APIs · Interactive reference

Was this page useful?