Artificial Intelligence is transforming how teams code and having clear visibility into tool usage and productivity is a game-changer. Thats where the Claude Code Analytics API, a powerful tool from Anthropic unlocks deep insights into how an organization leverages Claude Code, their AI-powered coding assistant. This API isn’t just about numbers—it’s about empowering teams to track developer activity, optimize workflows, and manage costs with precision. Whether you’re a project lead ensuring your team maximizes AI tools or a CTO justifying investments, the Claude Code Analytics API delivers actionable data to make informed decisions. In this guide, we’ll explore what this API does, its core features, how to use it, and why it’s a must-have for organizations scaling AI-assisted coding. Let’s dive in and see how the Claude Code Analytics API can transform your team’s productivity!
Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?
Apidog delivers all your demands, and replaces Postman at a much more affordable price!
What is the Claude Code Analytics API
The Claude Code Analytics API is like a window into your organization’s use of Claude Code, Anthropic’s AI coding assistant. It provides programmatic access to detailed usage analytics and productivity metrics, giving you a clear picture of how developers are interacting with Claude Code. Whether it’s tracking lines of code generated, monitoring API usage, or analyzing costs, this API is your go-to for transparency. Available as a dedicated endpoint under the Anthropic platform (/v1/organizations/usage_report/claude_code
), it’s designed for organizations using Claude Code to scale their development efforts. With the Claude Code Analytics API, you can answer critical questions like: Are developers fully utilizing Claude Code? Which tools are they using most? How much are we spending on AI models? This level of insight is invaluable for aligning AI adoption with business goals.

Core Features and Capabilities of Claude's Analytics API
What makes the Claude Code Analytics API stand out? It’s packed with features that cater to both technical and business needs. Here’s the rundown:
- Daily Aggregated Analytics: The API delivers metrics for a specific day, specified via the
starting_at
parameter. You get per-user and organization-wide data, making it easy to zoom in or out. - Developer Productivity Metrics: Track sessions, lines of code added or removed, commits, pull requests, and tool usage (like Claude’s Edit or Write features). This helps you see how Claude Code boosts your team’s output.
- Token and Cost Insights: Monitor token consumption and estimated costs, broken down by Claude model variants (e.g., Claude 3.7 Sonnet). Perfect for keeping budgets in check.
- Cursor-Based Pagination: Handle large datasets efficiently with opaque cursors, ensuring stable and scalable data retrieval.
- Data Freshness: Metrics are available with about a one-hour delay, ensuring consistency without real-time pressure.
These features make the Claude Code Analytics API a robust tool for understanding and optimizing Claude Code usage, whether you’re managing a small team or a large enterprise.
Technical Details and Usage
Ready to get your hands dirty with the Claude Code Analytics API? It’s a REST API, so it’s straightforward to use if you’re familiar with HTTP requests. The endpoint is /v1/organizations/usage_report/claude_code
, and you’ll need an Admin API key (starting with sk-ant-admin...
) to access it. You can generate this key in the Anthropic Console under Settings > API Keys, but only admins can do this—so make sure your organization is set up in Console > Settings > Organization.
Here’s a quick example to fetch analytics for a specific day using curl
:
curl "https://api.anthropic.com/v1/organizations/usage_report/claude_code?starting_at=2025-09-08&limit=20" \
--header "anthropic-version: 2023-06-01" \
--header "x-api-key: $ADMIN_API_KEY" \
--header "User-Agent: MyApp/1.0.0 (https://myapp.com)"
Let’s break it down:
- Endpoint:
/v1/organizations/usage_report/claude_code
- Parameters: Use
starting_at
to specify the date (e.g.,2025-09-08
) andlimit
to control results per request (e.g., 20 records). - Headers: Include
anthropic-version
for API versioning,x-api-key
for authentication, and aUser-Agent
to help Anthropic track usage patterns. - Pagination: If you’re dealing with large teams, the API uses cursor-based pagination. The response includes a
next_cursor
field to fetch the next batch.
The response is a JSON object with fields like user_id
, sessions
, lines_added
, lines_removed
, commits
, tool_usage
, and cost_usd
, giving you a detailed snapshot of activity. For full schema details, check Anthropic’s API reference at docs.anthropic.com.
Testing API Endpoints with Apidog
Before integrating the Claude Code Analytics API into your workflows, it’s smart to test your API endpoints to ensure everything’s running smoothly. That’s where Apidog comes in—a fantastic tool for designing, testing, and debugging APIs. Apidog is especially helpful for developers working on projects that rely on APIs like Claude Code Analytics. Here’s how you can use it:
- Get Started: Download Apidog from apidog.com/download or use the web version.
- Set Up Testing: Create a new project in Apidog and add the Claude Code Analytics endpoint (/v1/organizations/usage_report/claude_code). If Anthropic provides an OpenAPI spec, import it; otherwise, manually define the endpoint.
- Run Tests: Use Apidog’s test module to send requests with your API key and parameters (e.g., starting_at). Verify response schemas, status codes (expect 200 OK), and data accuracy.
- Debug Issues: Apidog’s visual interface helps you spot errors, like missing headers or invalid dates, ensuring your API calls are production-ready.

Testing with Apidog ensures your Claude Code Analytics API integration is rock-solid, saving you from surprises when scaling to dashboards or reporting tools. It’s a must for any project involving API-driven analytics.
Community-Built Dashboards with Claude Code Analytics API
The Claude Code Analytics API has sparked creativity in the developer community, leading to custom dashboards for visualizing usage. A prime example is the Claude Code Templates project, an open-source dashboard that runs locally to monitor all your Claude Code sessions in real-time.
Get Started: Install and run it directly with the command npx claude-code-templates@latest --analytics
. This spins up a local dashboard at localhost:3333
—ensuring no data leaves your machine. The dashboard features token usage charts, project activity breakdowns, and export capabilities. It's a powerful tool for developers to gain immediate, private insights into their AI workflow patterns and costs.

These community projects show how versatile the Claude Code Analytics API is. You can deploy these dashboards on your servers or cloud platforms like Vercel or Render, giving your team real-time insights into Claude Code usage.
Integration and Developer Experience
The Claude Code Analytics API is designed for seamless integration. Its RESTful nature and consistent JSON responses make it easy to plug into dashboards, billing systems, or custom tools. Here’s how you can make it work for you:
- Quick Start with Curl: The
curl
example above is perfect for prototyping. Test it in your terminal to see data flow instantly. - Build Dashboards: Integrate with tools like Grafana or Power BI. Feed API responses into visualizations to track KPIs like session counts or cost trends.
- Automate Reporting: Use scripts (e.g., Python with
requests
) to pull data daily and generate reports for stakeholders. - Scalable Retrieval: Cursor-based pagination ensures you can handle data for large teams without performance hiccups.
For example, a Python script to fetch and process data might look like this:
import requests
def fetch_claude_analytics(api_key, date, limit=20, cursor=None):
url = "https://api.anthropic.com/v1/organizations/usage_report/claude_code"
headers = {
"anthropic-version": "2023-06-01",
"x-api-key": api_key,
"User-Agent": "MyApp/1.0.0 (https://myapp.com)"
}
params = {"starting_at": date, "limit": limit}
if cursor:
params["cursor"] = cursor
response = requests.get(url, headers=headers, params=params)
response.raise_for_status()
return response.json()
# Example usage
api_key = "your-admin-api-key"
data = fetch_claude_analytics(api_key, "2025-09-08")
for record in data["records"]:
print(f"User: {record['user_id']}, Sessions: {record['sessions']}, Cost: ${record['cost_usd']:.2f}")
This script fetches data for a given date and prints key metrics. You can extend it to store results in a database or generate charts for your team.
Claude's Analytics API's Limitations and Considerations
While the Claude Code Analytics API is powerful, it has a few quirks to keep in mind:
- Admin Access Required: Only organization members with admin roles can access the API, so ensure your account has the right permissions.
- Data Privacy: Handle usage data carefully, as it includes user-specific metrics. Follow your org’s privacy policies to stay compliant.
- Scope Limitation: The API focuses on Claude Code usage, not other Claude APIs (e.g., conversational endpoints). If you need broader analytics, you’ll need additional tools.
These considerations don’t diminish the API’s value but help you plan its use effectively.
Conclusion
The Claude Code Analytics API is a must-have for organizations embracing AI-assisted coding with Claude Code. It offers unmatched visibility into developer activity, productivity, and costs, making it a cornerstone for data-driven decisions. Whether you’re building dashboards, optimizing budgets, or justifying AI investments, this API delivers the insights you need. Anthropic’s commitment to transparency shines through, and with potential future enhancements—like real-time data or deeper integrations—the Claude Code Analytics API is set to evolve further. So, grab your API key, fire up a curl
command, and start unlocking the full potential of your team’s Claude Code usage today!
