For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
ModelsChatRankingsDocs
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
    • Overview
    • Usage for Agents
  • TypeScript SDK
    • Overview
  • Python SDK
    • Overview
  • Go SDK
      • Analytics
      • APIKeys
      • Byok
      • Chat
      • Credits
      • Embeddings
      • Endpoints
      • Generations
      • Guardrails
      • OAuth
      • Observability
      • Organization
      • Presets
      • Providers
      • Rerank
      • Beta.Responses
      • Transcriptions
      • Speech
      • VideoGeneration
      • Workspaces
  • DevTools
    • Overview
    • Migrating to @openrouter/agent
LogoLogo
ModelsChatRankingsDocs
On this page
  • Overview
  • Available Operations
  • GetUserActivity
  • Example Usage
  • Parameters
  • Response
  • Errors
Go SDKAPI Reference

Analytics - Go SDK

Analytics method reference
Was this page helpful?
Previous

APIKeys - Go SDK

APIKeys method reference
Next
Built with

The Go SDK and docs are currently in beta. Report issues on GitHub.

Overview

Analytics and usage endpoints

Available Operations

  • GetUserActivity - Get user activity grouped by endpoint

GetUserActivity

Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. Management key required.

Example Usage

1package main
2
3import(
4 "context"
5 "os"
6 openrouter "github.com/OpenRouterTeam/go-sdk"
7 "log"
8)
9
10func main() {
11 ctx := context.Background()
12
13 s := openrouter.New(
14 openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
15 )
16
17 res, err := s.Analytics.GetUserActivity(ctx, nil, nil, nil)
18 if err != nil {
19 log.Fatal(err)
20 }
21 if res != nil {
22 // handle response
23 }
24}

Parameters

ParameterTypeRequiredDescriptionExample
ctxcontext.Context✔️The context to use for the request.
date*string➖Filter by a single UTC date in the last 30 days (YYYY-MM-DD format).2025-08-24
apiKeyHash*string➖Filter by API key hash (SHA-256 hex string, as returned by the keys API).abc123def456…
userID*string➖Filter by org member user ID. Only applicable for organization accounts.user_abc123
opts[]operations.Option➖The options for this request.

Response

*components.ActivityResponse, error

Errors

Error TypeStatus CodeContent Type
sdkerrors.BadRequestResponseError400application/json
sdkerrors.UnauthorizedResponseError401application/json
sdkerrors.ForbiddenResponseError403application/json
sdkerrors.NotFoundResponseError404application/json
sdkerrors.InternalServerResponseError500application/json
sdkerrors.APIError4XX, 5XX*/*