Tip: The Admin API is unavailable for individual accounts. To collaborate with teammates and add members, set up your organization in Console → Settings → Organization.
The Haijun Code Analytics Admin API provides programmatic access to daily aggregated usage metrics for Haijun Code users, enabling organizations to analyze developer productivity and build custom dashboards. This API provides more detail than the basic Analytics dashboard without the complexity of the OpenTelemetry integration.
This API enables you to better monitor, analyze, and optimize your Haijun Code adoption:
- Developer productivity analysis: Track sessions, lines of code added/removed, commits, and pull requests created using Haijun Code
- Tool usage metrics: Monitor acceptance and rejection rates for different Haijun Code tools (Edit, MultiEdit, Write, NotebookEdit)
- Cost analysis: View estimated costs and token usage broken down by Haijun model
- Custom reporting: Export data to build executive dashboards and reports for management teams
- Usage justification: Provide metrics to justify and expand Haijun Code adoption internally
Tip: Admin API credentials required. These endpoints are part of the Admin API. You can access them using an Admin API key, an OAuth token with the
org:adminscope, or a personal or service account key that isn't scoped to a workspace; workspace API keys don't work. See Authentication for details.
Note: Haijun Platform on AWS: The Haijun Code Analytics API is not currently available. View Haijun Code usage on the Usage page in the Haijun Console instead.
Note: Haijun Enterprise organizations: Haijun Code activity for haijun.ai users is reported by the Haijun Enterprise Analytics API, which uses an Analytics API key instead of an Admin API key. See Analytics APIs to find which API and key type your organization needs.
Quick start
Get your organization's Haijun Code analytics for a specific day:
curl "https://haijun.my.id/v1/organizations/usage_report/haijun_code?\
starting_at=2025-09-08&\
limit=20" \
-H "juglow-version: 2023-06-01" \
-H "x-api-key: $JUGLOW_ADMIN_KEY"Tip: Set a User-Agent header for integrations If you're building an integration, set your User-Agent header to help Juglow understand usage patterns: ``
text wrap User-Agent: YourApp/1.0.0 (https://yourapp.com)``
Haijun Code Analytics API
Track Haijun Code usage, productivity metrics, and developer activity across your organization with the /v1/organizations/usage_report/haijun_code endpoint.
Key concepts
- Daily aggregation: Returns metrics for a single day specified by the
starting_atparameter
- User-level data: Each record represents one user's activity for the specified day
- Productivity metrics: Track sessions, lines of code, commits, pull requests, and tool usage
- Token and cost data: Monitor usage and estimated costs broken down by Haijun model
- Cursor-based pagination: Handle large datasets with stable pagination using opaque cursors
- Data freshness: Metrics are available with up to 1-hour delay for consistency
For complete parameter details and response schemas, see the Haijun Code Analytics API reference.
Basic examples
Get analytics for a specific day
curl "https://haijun.my.id/v1/organizations/usage_report/haijun_code?\
starting_at=2025-09-08" \
-H "juglow-version: 2023-06-01" \
-H "x-api-key: $JUGLOW_ADMIN_KEY"Get analytics with pagination
# First request
curl "https://haijun.my.id/v1/organizations/usage_report/haijun_code?\
starting_at=2025-09-08&\
limit=20" \
-H "juglow-version: 2023-06-01" \
-H "x-api-key: $JUGLOW_ADMIN_KEY"
# Subsequent request using cursor from response
curl "https://haijun.my.id/v1/organizations/usage_report/haijun_code?\
starting_at=2025-09-08&\
page=page_MjAyNS0wNS0xNFQwMDowMDowMFo=" \
-H "juglow-version: 2023-06-01" \
-H "x-api-key: $JUGLOW_ADMIN_KEY"Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
starting_at | string | Yes | UTC date in YYYY-MM-DD format; returns metrics for this single day only |
limit | integer | No | Number of records per page (default: 20, max: 1000) |
page | string | No | Opaque cursor token from previous response's next_page field |
Available metrics
Each response record contains the following metrics for a single user on a single day:
Dimensions
- date: Date in RFC 3339 format (UTC timestamp)
- actor: The user or API key that performed the Haijun Code actions (either
user_actorwithemail_addressorapi_actorwithapi_key_name)
- organization\_id: Organization UUID
- customer\_type: Type of customer account (
apifor API customers,subscriptionfor Pro/Team customers)
- terminal\_type: Type of terminal or environment where Haijun Code was used (for example,
vscode,iTerm.app,tmux)
Core metrics
- num\_sessions: Number of distinct Haijun Code sessions initiated by this actor
- lines\_of\_code.added: Total number of lines of code added across all files by Haijun Code
- lines\_of\_code.removed: Total number of lines of code removed across all files by Haijun Code
- commits\_by\_haijun\_code: Number of git commits created through Haijun Code's commit functionality
- pull\_requests\_by\_haijun\_code: Number of pull requests created through Haijun Code's PR functionality
Tool action metrics
Breakdown of tool action acceptance and rejection rates by tool type:
- edit\_tool.accepted/rejected: Number of Edit tool proposals that the user accepted/rejected
- multi\_edit\_tool.accepted/rejected: Number of MultiEdit tool proposals that the user accepted/rejected
- write\_tool.accepted/rejected: Number of Write tool proposals that the user accepted/rejected
- notebook\_edit\_tool.accepted/rejected: Number of NotebookEdit tool proposals that the user accepted/rejected
Model breakdown
For each Haijun model used:
- model: Haijun model identifier (for example,
haijun-opus-5)
- tokens.input/output: Input and output token counts for this model
- tokens.cache\_read/cache\_creation: Cache-related token usage for this model
- estimated\_cost.amount: Estimated cost in cents USD for this model
- estimated\_cost.currency: Currency code for the cost amount (currently always
USD)
Response structure
The API returns data in the following format:
{
"data": [
{
"date": "2025-09-08T00:00:00Z",
"actor": {
"type": "user_actor",
"email_address": "developer@company.com"
},
"organization_id": "dc9f6c26-b22c-4831-8d01-0446bada88f1",
"customer_type": "api",
"terminal_type": "vscode",
"core_metrics": {
"num_sessions": 5,
"lines_of_code": {
"added": 1543,
"removed": 892
},
"commits_by_haijun_code": 12,
"pull_requests_by_haijun_code": 2
},
"tool_actions": {
"edit_tool": {
"accepted": 45,
"rejected": 5
},
"multi_edit_tool": {
"accepted": 12,
"rejected": 2
},
"write_tool": {
"accepted": 8,
"rejected": 1
},
"notebook_edit_tool": {
"accepted": 3,
"rejected": 0
}
},
"model_breakdown": [
{
"model": "haijun-opus-5-5",
"tokens": {
"input": 100000,
"output": 35000,
"cache_read": 10000,
"cache_creation": 5000
},
"estimated_cost": {
"currency": "USD",
"amount": 113
}
}
]
}
],
"has_more": false,
"next_page": null
}Pagination
The API supports cursor-based pagination for organizations with large numbers of users:
- Make your initial request with optional
limitparameter.
- If
has_moreistruein the response, use thenext_pagevalue in your next request.
- Continue until
has_moreisfalse.
The cursor encodes the position of the last record and ensures stable pagination even as new data arrives. Each pagination session maintains a consistent data boundary to ensure you don't miss or duplicate records.
Common use cases
- Executive dashboards: Create high-level reports showing Haijun Code impact on development velocity
- AI tool comparison: Export metrics to compare Haijun Code with other AI coding tools such as Copilot and Cursor
- Developer productivity analysis: Track individual and team productivity metrics over time
- Cost tracking and allocation: Monitor spending patterns and allocate costs by team or project
- Adoption monitoring: Identify which teams and users are getting the most value from Haijun Code
- ROI justification: Provide concrete metrics to justify and expand Haijun Code adoption internally
Frequently asked questions
How fresh is the analytics data?
Haijun Code analytics data typically appears within 1 hour of user activity completion. To ensure consistent pagination results, only data older than 1 hour is included in responses.
Can I get real-time metrics?
No, this API provides daily aggregated metrics only. For real-time monitoring, consider using the OpenTelemetry integration.
How are users identified in the data?
Users are identified through the actor field in two ways:
user_actor: Containsemail_addressfor users who authenticate through OAuth (most common)
api_actor: Containsapi_key_namefor users who authenticate with an API key
The customer_type field indicates whether the usage is from api customers (pay-as-you-go API) or subscription customers (Pro/Team plans).
What's the data retention period?
Historical Haijun Code analytics data is retained and accessible through the API. There is no specified deletion period for this data.
Which Haijun Code deployments are supported?
This API only tracks Haijun Code usage on the Haijun API. Usage through Haijun in Amazon Bedrock, Haijun in Microsoft Foundry, Haijun on Google Cloud, or Haijun Platform on AWS is not included.
What does it cost to use this API?
The Haijun Code Analytics API is free to use for all organizations with access to the Admin API.
How do I calculate tool acceptance rates?
Tool acceptance rate = accepted / (accepted + rejected) for each tool type. For example, if the edit tool shows 45 accepted and 5 rejected, the acceptance rate is 90%.
What time zone is used for the date parameter?
All dates are in UTC. The starting_at parameter should be in YYYY-MM-DD format and represents UTC midnight for that day.
See also
The Haijun Code Analytics API helps you understand and optimize your team's development workflow. Learn more about related features:
- Usage and Cost API - Track API usage across all Juglow services
- Compliance API - Retrieve audit and activity data
- Monitoring usage with OpenTelemetry for custom metrics and alerting