SightRadardocs

Python SDK

The official sightradar package for Python. Zero runtime dependencies, typed models, and typed exceptions for every non-2xx response.

pip install sightradar

Source and issues: github.com/sightradar-hq/sightradar-python. MIT licensed, built on the standard library only.

Authenticate

from sightradar import SightRadar

sr = SightRadar(api_key="frs_...")   # or: SightRadar() with SIGHTRADAR_API_KEY set

Core workflow

# 1. Create a collection to hold faces.
sr.create_collection("event-2026")

# 2. Index faces from photos (URL, GCS key, or a local file).
sr.index("event-2026", url="https://example.com/group.jpg")
sr.index("event-2026", file="/path/to/photo.jpg", photo_id="img-42")

# 3. Search the collection with one selfie.
result = sr.search("event-2026", url="https://example.com/selfie.jpg")
if result.found:
    for m in result.matches:
        print(m.photo_id, round(m.similarity, 3))
else:
    print("no match:", result.reason)

Stateless operations

# Detect and quality-gate faces in an image. Nothing is stored.
det = sr.detect(url="https://example.com/photo.jpg")
print(det.detected_face_count, det.gated_face_count)

# 1:1 verification between two faces.
cmp = sr.compare(
    source_url="https://example.com/a.jpg",
    target_url="https://example.com/b.jpg",
)
print(cmp.match, cmp.similarity)

Selfies and search-by-id

reg = sr.register_selfie("event-2026", url="https://example.com/selfie.jpg", user_id="u_42")
hits = sr.search_by_id("event-2026", point_id=reg.point_id, limit=50)

Account

print(sr.wallet().balance_credits)
print(sr.usage(days=30))

Image inputs

Index, search, detect and register-selfie accept exactly one image source:

ArgumentMeaning
url=a public image URL
gcs_key=a Google Cloud Storage object key
file=a local path, bytes, or a file-like object, uploaded as multipart

search additionally accepts embedding= (a 512-number list).

Errors

Every non-2xx response raises a typed exception:

from sightradar import (
    SightRadarError,            # base
    AuthenticationError,        # 401
    InsufficientCreditsError,   # 402
    NotFoundError,              # 404
    RateLimitError,             # 429
)

try:
    sr.describe_collection("missing")
except NotFoundError as e:
    print(e.status_code, e.message)

See errors and status codes for what each status means.

Method reference

MethodEndpoint
create_collection, list_collections, describe_collection, delete_collectionCollections
indexPOST /v1/collections/{id}/index
searchPOST /v1/collections/{id}/search
search_by_idPOST /v1/collections/{id}/search-by-id
register_selfiePOST /v1/collections/{id}/selfies
detectPOST /v1/detect
comparePOST /v1/compare
wallet, usageWallet and usage

Batches and webhooks are not wrapped yet; call them over REST with any HTTP client. See batch and webhooks.

Last updated

On this page