Skip to content

Commit

Permalink
docs: add session data export endpoint documentation (#594)
Browse files Browse the repository at this point in the history
* docs: improve JWT token retrieval documentation

- Add get_session_jwt() documentation in sdk-reference.mdx
- Add Session Authentication section in sessions.mdx
- Document JWT token retrieval process

Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>

* docs: update session data export documentation

Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>

* docs: simplify session data export authentication to use only API key

Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Alex Reibman <meta.alex.r@gmail.com>
  • Loading branch information
devin-ai-integration[bot] and areibman authored Dec 20, 2024
1 parent c3fceb1 commit f844e0a
Showing 1 changed file with 60 additions and 2 deletions.
62 changes: 60 additions & 2 deletions docs/v1/concepts/sessions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,66 @@ agentops.init(inherited_session_id=<id>)

Both processes will now contribute data to the same session.

## Session Data Export
AgentOps provides REST endpoints to export your session data and statistics. These endpoints allow you to retrieve detailed information about your sessions programmatically.

### Authentication
All data export requests require a single header:
- `X-Agentops-Api-Key`: Your AgentOps API key

### Available Endpoints

#### Get Session Statistics
```http
GET /v2/sessions/<session_id>/stats
```

Returns statistics for the specified session including:
- Event counts
- Duration
- Costs
- Token usage
- Other session metrics

#### Export Complete Session Data
```http
GET /v2/sessions/<session_id>/export
```

Returns comprehensive session data including:
- Session metadata
- Statistics
- All recorded events:
- Actions
- LLM calls
- Tool usage
- Errors

### Example Usage
```python
import requests

# Your AgentOps API key
api_key = "your-api-key"
session_id = "your-session-id"

headers = {
"X-Agentops-Api-Key": api_key
}

# Get session stats
stats_url = f"https://api.agentops.ai/v2/sessions/{session_id}/stats"
stats_response = requests.get(stats_url, headers=headers)
stats = stats_response.json()

# Export complete session data
export_url = f"https://api.agentops.ai/v2/sessions/{session_id}/export"
export_response = requests.get(export_url, headers=headers)
session_data = export_response.json()
```

## Session Analytics
You can retrieve the analytics for a session by calling `session.get_analytics()`.
You can retrieve the analytics for a session by calling `session.get_analytics()`.

The example below shows how to record events and retrieve analytics.

Expand Down Expand Up @@ -127,4 +185,4 @@ be applied. You can also apply different configuration options when you start a
[Configuration](/v1/usage/sdk-reference/#configuration) object.

<script type="module" src="/scripts/github_stars.js"></script>
<script type="module" src="/scripts/adjust_api_dynamically.js"></script>
<script type="module" src="/scripts/adjust_api_dynamically.js"></script>

0 comments on commit f844e0a

Please sign in to comment.