How to Use the Spyglasses API
Spyglasses provides an OpenAPI-compatible REST API that allows you to programmatically access your analytics data. This is useful for building custom integrations, dashboards, or automating workflows.
Overview
The Spyglasses API uses your property's API key for authentication. You can access analytics data, AI visibility rankings, historical metrics, and more through simple HTTP requests.
Getting Started
1. Find Your API Key
Your API key is located in your property settings:
- Navigate to your Spyglasses dashboard
- Select your property from the sidebar
- Go to Settings
- Find the API Key section
- Click the copy button to copy your API key
Your API key looks like: sg_XXXXXXXX-XXXX_XXXXXXXXXXXXXXXXXXXXXXXXXXXX
Keep your API key secure! Anyone with your API key can access your analytics data. Never commit it to version control or expose it in client-side code.
2. Explore the API Documentation
Before integrating, we recommend exploring the interactive API documentation:
- Visit the External API Reference page
- Browse available endpoints
- Test endpoints directly in the browser using your API key
3. Make Your First Request
Test your API key by fetching your property details:
This returns your property information including the propertyId you'll need for other API calls:
Authentication
All API requests must include your API key in the x-api-key header:
Available Endpoints
Not all API endpoints documented are available for use with an API key. If you get an error using an endpoint, confirm it's part of the list of externally-accessible endpoints. See the External API Endpoints page for a complete list of API-accessible endpoints.
Error Handling
The API returns standard HTTP status codes:
| Status Code | Description |
|---|---|
200 | Success |
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Invalid or missing API key |
403 | Forbidden - Access denied to the requested resource |
404 | Not Found - Resource doesn't exist |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error |
Error responses include a JSON body with details:
Need Help?
- Check the External API Reference for endpoint details
- Contact us at support@spyglasses.io