Best Practices
Date Range Selection
# Last 7 days
curl "https://sso.example.com/api/organizations/acme-corp/analytics/login-trends?start_date=$(date -u -d '7 days ago' +%Y-%m-%d)&end_date=$(date -u +%Y-%m-%d)" \
-H "Authorization: Bearer eyJhbGc..."
# Current month
START_DATE=$(date -u +%Y-%m-01)
END_DATE=$(date -u +%Y-%m-%d)
curl "https://sso.example.com/api/organizations/acme-corp/analytics/login-trends?start_date=$START_DATE&end_date=$END_DATE" \
-H "Authorization: Bearer eyJhbGc..."
Combining Multiple Analytics
# Fetch all analytics data in parallel for a dashboard
ORG="acme-corp"
TOKEN="eyJhbGc..."
BASE_URL="https://sso.example.com"
curl "$BASE_URL/api/organizations/$ORG/analytics/login-trends" \
-H "Authorization: Bearer $TOKEN" &
curl "$BASE_URL/api/organizations/$ORG/analytics/logins-by-service" \
-H "Authorization: Bearer $TOKEN" &
curl "$BASE_URL/api/organizations/$ORG/analytics/logins-by-provider" \
-H "Authorization: Bearer $TOKEN" &
curl "$BASE_URL/api/organizations/$ORG/analytics/recent-logins?limit=20" \
-H "Authorization: Bearer $TOKEN" &
wait
Pagination for Large Result Sets
For recent logins with high volume:
# First 100 results
curl "https://sso.example.com/api/organizations/acme-corp/analytics/recent-logins?limit=100" \
-H "Authorization: Bearer eyJhbGc..."
# Note: The API does not support offset-based pagination
# To get older records, use date-filtered queries on login-trends
Related Documentation
- Organizations API - Organization management
- Services API - Service configuration
- Audit Logs API - Administrative action tracking
- SDK Analytics Module - TypeScript SDK for analytics