Skip to main content
Spyglass

The API layer for the social internet

Official Python SDK for the Spyglass API — search brands, creators, and the ads they run.

Get Started Documentation spyglass.so


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 (count in the response). Always bound requests with limit. See Billing docs.
  • Pagination: Page through results with offset and limit. count is the number of rows in the current response.
  • Server-to-server: Call the API from your backend, data pipeline, or agent runtime.

Support

License

MIT

Metadata

Release files for spyglass-sdk 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spyglass-sdk 0.1.2
File Size Uploaded
spyglass_sdk-0.1.2.tar.gz 68.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spyglass-sdk 0.1.2
File Interpreter ABI Platform
spyglass_sdk-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 181.0 kB

Release files / spyglass_sdk-0.1.2.tar.gz

Download URL spyglass_sdk-0.1.2.tar.gz
Size 68.0 kB
Tags Source
SHA-256 checksum
How to use checksums
eb77f51ab69e71ebc24a9914d6edc6bd20d48e171efdca1ebc0f8a698ffdb215
BLAKE2b-256 checksum
How to use checksums
c670470b9b822de5856ef1ea8e4d4410cc74ca9ff4aa50110a34b45a2a92b337
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

Release files / spyglass_sdk-0.1.2-py3-none-any.whl

Download URL spyglass_sdk-0.1.2-py3-none-any.whl
Size 112.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a8f4c8af9b8952c1be2274330a4524409d85335d8ab09a275a28895926af3b5
BLAKE2b-256 checksum
How to use checksums
91df103ee0947ebdfc53e31664e78131925492e65aef6f3bb099884ac3a8877c
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

Release history Release notifications | RSS feed

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

This release

0.1.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page