Introduction
The AstraNetmon API provides read-only programmatic access to your monitoring data. Use it to:
- Build custom dashboards
- Integrate with third-party analytics tools
- Create automated reports
- Export data to other systems
Authentication
The API supports two authentication methods:
1. Session-Based Authentication
When logged into the dashboard, you're automatically authenticated for API requests. This is useful for browser-based applications.
2. API Key Authentication
For programmatic access, use API keys. Generate a read-only API key from: Dashboard → Settings → Alerts
curl -H "Authorization: Bearer astra_your_api_key_here" \
https://your-org.astraid.io/api/v1/agentsWarning
Security: API keys are only shown once upon creation. Store them securely and never commit them to version control.
Base URL
All API endpoints are relative to your AstraNetmon domain:
https://your-org.astraid.io/api/v1Available Endpoints
GET /api/v1/agents
List all agents for your account
Required Permission: read:agents
GET /api/v1/metrics
Query network metrics (latency, jitter, packet loss per target)
Required Permission: read:metrics
Query Parameters:
- agent_id (optional)
- start_date (optional, ISO format)
- end_date (optional, ISO format)
- limit (optional, max 10000)
GET /api/v1/speedtests
Access speed test results
Required Permission: read:speedtests
Query Parameters:
- agent_id (optional)
- start_date (optional)
- end_date (optional)
- limit (optional, max 1000)
GET /api/v1/traceroutes
Access traceroute results
Required Permission: read:traceroutes
Query Parameters: Same as speedtests
For detailed endpoint documentation, see the API Endpoints Reference.
Quick Start Examples
Python
import requests
API_KEY = "astra_your_api_key_here"
BASE_URL = "https://your-org.astraid.io/api/v1"
headers = {
"Authorization": f"Bearer {API_KEY}"
}
# Get all agents
response = requests.get(f"{BASE_URL}/agents", headers=headers)
agents = response.json()["agents"]
for agent in agents:
print(f"{agent['hostname']}: {agent['status']}")
# Get recent metrics
params = {
"agent_id": "agent-123",
"limit": 100
}
response = requests.get(f"{BASE_URL}/metrics", headers=headers, params=params)
metrics = response.json()["metrics"]
print(f"Retrieved {len(metrics)} metrics")JavaScript/Node.js
const API_KEY = "astra_your_api_key_here";
const BASE_URL = "https://your-org.astraid.io/api/v1";
const headers = {
"Authorization": `Bearer ${API_KEY}`
};
// Get all agents
const agentsResponse = await fetch(`${BASE_URL}/agents`, { headers });
const { agents } = await agentsResponse.json();
agents.forEach(agent => {
console.log(`${agent.hostname}: ${agent.status}`);
});
// Get metrics with filters
const params = new URLSearchParams({
agent_id: "agent-123",
limit: "100"
});
const metricsResponse = await fetch(`${BASE_URL}/metrics?${params}`, { headers });
const { metrics } = await metricsResponse.json();
console.log(`Retrieved ${metrics.length} metrics`);cURL
# Get all agents
curl -H "Authorization: Bearer astra_your_api_key_here" \
https://your-org.astraid.io/api/v1/agents
# Get metrics for specific agent
curl -H "Authorization: Bearer astra_your_api_key_here" \
"https://your-org.astraid.io/api/v1/metrics?agent_id=agent-123&limit=100"
# Get speed tests from last 7 days
START_DATE=$(date -u -d '7 days ago' '+%Y-%m-%dT%H:%M:%SZ')
curl -H "Authorization: Bearer astra_your_api_key_here" \
"https://your-org.astraid.io/api/v1/speedtests?start_date=$START_DATE"Response Format
All API responses follow a consistent JSON format:
Success Response
{
"agents": [...],
"total": 5
}Error Response
{
"error": "Error message description"
}HTTP status codes:
- 200 OK: Request succeeded
- 401 Unauthorized: Missing or invalid API key
- 403 Forbidden: Insufficient permissions
- 500 Internal Server Error: Server-side error
Rate Limiting
API rate limits depend on your subscription plan:
| Plan | Rate Limit |
|---|---|
| Starter | 100 requests/hour |
| Professional | 1,000 requests/hour |
| Enterprise | Unlimited |
Note
Rate limits are per API key. If you hit the limit, you'll receive a 429 status code. Wait before retrying.
Best Practices
- Cache responses when possible to reduce API calls
- Use date filters to limit the amount of data returned
- Handle errors gracefully with proper retry logic
- Store API keys securely in environment variables
- Monitor usage to stay within rate limits
- Use appropriate permissions - only request what you need