Documentation

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:

  1. Navigate to your Spyglasses dashboard
  2. Select your property from the sidebar
  3. Go to Settings
  4. Find the API Key section
  5. 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:

  1. Visit the External API Reference page
  2. Browse available endpoints
  3. Test endpoints directly in the browser using your API key

3. Make Your First Request

Test your API key by fetching your property details:

curl -X GET "https://spyglasses.io/api/me" \
  -H "x-api-key: YOUR_API_KEY"

This returns your property information including the propertyId you'll need for other API calls:

{
  "propertyId": "cm9ovvnnc0001wjubh0en0cpe",
  "domain": "example.com",
  "companyName": "Example Company",
  "apiKey": "sg_XXXX...",
  "verified": true,
  "verifiedAt": "2025-01-01T00:00:00.000Z",
  "blockAiModelTrainers": false,
  "customBlocks": [],
  "customAllows": []
}

Authentication

All API requests must include your API key in the x-api-key header:

curl -X GET "https://spyglasses.io/api/endpoint" \
  -H "x-api-key: YOUR_API_KEY"

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 CodeDescription
200Success
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Access denied to the requested resource
404Not Found - Resource doesn't exist
429Too Many Requests - Rate limit exceeded
500Internal Server Error

Error responses include a JSON body with details:

{
  "error": "Description of what went wrong"
}

Need Help?

On this page