The API layer for the social internet
Official Python SDK for the Spyglass API — search brands, creators, and the ads they run.
spyglass-sdk is the official Python client for the Spyglass API with both synchronous (Spyglass) and asynchronous (AsyncSpyglass) clients. Resolve brands and creators, search across millions of Meta, Instagram, and TikTok creatives with natural-language briefs or structured filters, and extract hooks, personas, landing pages, and public comments.
Looking for TypeScript / Node.js? See
spyglass-so/spyglass-typescript(npm install @spyglasshq/sdk).
Installation
pip install spyglass-sdk
# or
uv add spyglass-sdk
Quickstart
Create an API key in Settings → API. Keys start with sg_live_ and are shown once.
import os
from spyglass import Spyglass
client = Spyglass(token=os.environ["SPYGLASS_API_KEY"])
# 1. Resolve a brand
result = client.search.brands(names=["Nike"], limit=1)
if result.brands:
brand = result.brands[0]
# 2. Search the creatives that brand is running
media_result = client.search.get_media(
brand_id=brand.id,
query="marathon running shoes comfort",
limit=10,
)
for ad in media_result.media:
print(ad.id, ad.hook, ad.core_angle, ad.url)
Async Usage
Use AsyncSpyglass for non-blocking calls with asyncio:
import asyncio
import os
from spyglass import AsyncSpyglass
client = AsyncSpyglass(token=os.environ["SPYGLASS_API_KEY"])
async def main() -> None:
result = await client.search.brands(names=["Nike"], limit=3)
for brand in result.brands:
print(brand.id, brand.name)
asyncio.run(main())
API Reference Overview
| SDK Method | HTTP Endpoint | Cost | Rate Limit |
|---|---|---|---|
client.search.brands(...) |
POST /brands |
$0.0020 / brand returned | 120 / min |
client.search.creators(...) |
POST /creators |
$0.0020 / creator returned | 120 / min |
client.search.get_account(id=...) |
GET /account/{id} |
$0.0020 / account returned | 120 / min |
client.search.get_media(...) |
POST /media |
$0.0010 / creative returned | 120 / min |
client.search.taxonomies(query=...) |
GET /taxonomies |
Free | 120 / min |
client.search.get_brand_media_insights(...) |
GET /account/{id}/insights |
$0.0010 / cluster returned | 120 / min |
client.search.get_brand_landing_pages(...) |
GET /account/{id}/landing-pages |
$0.0050 / landing page returned | 120 / min |
client.search.get_comments(...) |
POST /comments |
$0.0100 / live page fetched | 20 / min |
client.indexing.index_brand(...) |
POST /account/index |
Free | 50 / min |
client.indexing.index_brand_status(id=...) |
GET /account/{id}/index-status |
Free | 300 / min |
client.account.get_credit_usage() |
GET /team/credit-usage |
Free | 120 / min |
Full parameters and response schemas are documented in reference.md and at docs.spyglass.so.
Indexing a New Brand
If Spyglass doesn't have a brand yet, queue it by website or social profile URL (POST /account/index is free) and poll until status is "ready":
import time
indexed = client.indexing.index_brand(website_url="https://www.on.com")
status = indexed.status
while status == "indexing":
time.sleep(3)
check = client.indexing.index_brand_status(id=indexed.brand_id)
status = check.status
Error Handling
Non-2xx responses raise an ApiError with status code and parsed error body:
from spyglass.core.api_error import ApiError
try:
client.search.brands(names=["Nike"], limit=5)
except ApiError as e:
print(e.status_code, e.body)
Advanced Options
Retries & Timeouts
Requests default to a 60-second timeout and up to 2 automatic retries with exponential backoff on 408, 409, 429, and 5xx responses. Override at the client or per-request level:
client = Spyglass(token="...", timeout=30.0, max_retries=3)
response = client.search.brands(
names=["Nike"],
limit=5,
request_options={"timeout_in_seconds": 15, "max_retries": 1},
)
Raw Response & Headers
Use .with_raw_response to inspect HTTP headers and status codes:
raw = client.search.with_raw_response.brands(names=["Nike"], limit=1)
print(raw.status_code)
print(raw.headers)
print(raw.data.brands)
Custom HTTPX Client
Pass a custom httpx.Client or httpx.AsyncClient for custom proxies or transport settings:
import httpx
from spyglass import Spyglass
client = Spyglass(
token="...",
httpx_client=httpx.Client(proxy="http://proxy.example.com"),
)
Billing & Conventions
- Credits: Most calls spend monthly credits per row returned (
countin the response). Always bound requests withlimit. See Billing docs. - Pagination: Page through results with
offsetandlimit.countis the number of rows in the current response. - Server-to-server: Call the API from your backend, data pipeline, or agent runtime.
Support
- Documentation: docs.spyglass.so
- Issues: github.com/spyglass-so/spyglass-python/issues
- Email: support@spyglass.so
License
Metadata
Release files for spyglass-sdk 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| spyglass_sdk-0.1.3.tar.gz | 66.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| spyglass_sdk-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 173.2 kB
Release files / spyglass_sdk-0.1.3.tar.gz
| Download URL | spyglass_sdk-0.1.3.tar.gz |
|---|---|
| Size | 66.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac3423b2deb333993f8edcf34ec8098785bf2d1f95bf96f7c1be8d78e8e4401c
|
|
BLAKE2b-256 checksum How to use checksums |
b679179e5b9d644506da9489d33b4f10522f9b21c43457547817bdb755d2a5e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logRelease files / spyglass_sdk-0.1.3-py3-none-any.whl
| Download URL | spyglass_sdk-0.1.3-py3-none-any.whl |
|---|---|
| Size | 106.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fc2f2cf2e6979539cca4892cfadbde7bfef7d106d4fb973f95399085b3f0cfd2
|
|
BLAKE2b-256 checksum How to use checksums |
ef571cc179210c3ec035b63ba10ff13144769a12c959e084e859fc067b97006e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency log