Access your monitoring data programmatically with the AstraNetmon REST API
The AstraNetmon API provides read-only programmatic access to your monitoring data. Use it to:
The API supports two authentication methods:
When logged into the dashboard, you're automatically authenticated for API requests. This is useful for browser-based applications.
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-domain.com/api/v1/agentsSecurity: API keys are only shown once upon creation. Store them securely and never commit them to version control.
All API endpoints are relative to your AstraNetmon domain:
https://your-domain.astraid.io/api/v1List all agents for your account
Required Permission: read:agents
Query system metrics (CPU, memory, disk, network)
Required Permission: read:metrics
Query Parameters:
Access speed test results
Required Permission: read:speedtests
Query Parameters:
Access traceroute results
Required Permission: read:traceroutes
Query Parameters: Same as speedtests
For detailed endpoint documentation, see the API Endpoints Reference.
import requests
API_KEY = "astra_your_api_key_here"
BASE_URL = "https://your-domain.com/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")const API_KEY = "astra_your_api_key_here";
const BASE_URL = "https://your-domain.com/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`);# Get all agents
curl -H "Authorization: Bearer astra_your_api_key_here" \
https://your-domain.com/api/v1/agents
# Get metrics for specific agent
curl -H "Authorization: Bearer astra_your_api_key_here" \
"https://your-domain.com/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-domain.com/api/v1/speedtests?start_date=$START_DATE"All API responses follow a consistent JSON format:
{
"agents": [...],
"total": 5
}{
"error": "Error message description"
}HTTP status codes:
API rate limits depend on your subscription plan:
| Plan | Rate Limit |
|---|---|
| Starter | 100 requests/hour |
| Professional | 1,000 requests/hour |
| Enterprise | Unlimited |
Rate limits are per API key. If you hit the limit, you'll receive a 429 status code. Wait before retrying.