# Quickstart

> From zero to your first face match in four calls. Create an API key, index a face, search the collection with a selfie, and check your credit balance.

Source: https://sightradar.com/docs/quickstart

Every call below is a real request against the production API at `https://api.sightradar.com`. New accounts start with trial credits, so you can run the whole guide for free.

### Get an API key

Sign in to the [console](/login) and open **API Keys → Create key**. The key starts with `frs_` and is shown **once**. Export it so the snippets below pick it up:

```bash title="shell"
export SIGHTRADAR_API_KEY="frs_xxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export SR_BASE="https://api.sightradar.com"
export SR_API_KEY="$SIGHTRADAR_API_KEY"  # short alias used by some older guide snippets
```

`SIGHTRADAR_API_KEY` is the variable both SDKs and the CLI read. Every request authenticates with `Authorization: Bearer $SIGHTRADAR_API_KEY`. See [Authentication](/docs/authentication) for key rotation and limits.

### Create a collection

A collection is the namespace your faces live in, for example one per event. This call is free.

_curl_
```bash
curl -X POST "$SR_BASE/v1/collections" \
  -H "Authorization: Bearer $SIGHTRADAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"collection_id": "quickstart-demo"}'
```

_Python_
```python
from sightradar import SightRadar

sr = SightRadar()  # reads SIGHTRADAR_API_KEY
sr.create_collection("quickstart-demo")
```

_Node_
```ts
import { SightRadar } from "sightradar";

const sr = new SightRadar(); // reads SIGHTRADAR_API_KEY
await sr.createCollection("quickstart-demo");
```

```json title="200 response"
{
  "collection_id": "quickstart-demo",
  "status": "active",
  "photo_count": 0,
  "face_count": 0,
  "selfie_count": 0,
  "created_at": "2026-06-22T19:40:00Z"
}
```

### Index a face

Send a photo by URL (or a multipart `file`, or raw bytes). SightRadar detects every quality-gated face and stores its faceprint. Pass a `photoId` so you can find the photo later. **Billable: 93 credits.**

_curl_
```bash
curl -X POST "$SR_BASE/v1/collections/quickstart-demo/index" \
  -H "Authorization: Bearer $SIGHTRADAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/group-photo.jpg", "photoId": "photo-001"}'
```

_Python_
```python
sr.index("quickstart-demo", url="https://example.com/group-photo.jpg", photo_id="photo-001")
```

_Node_
```ts
await sr.index("quickstart-demo", { url: "https://example.com/group-photo.jpg", photoId: "photo-001" });
```

```json title="200 response"
{
  "collection_id": "quickstart-demo",
  "photo_id": "photo-001",
  "indexed": 3,
  "detected_face_count": 3,
  "rejected_face_count": 0,
  "faces": [
    { "face_index": 0, "point_id": "…", "det_score": 0.84, "min_px": 120, "bbox": { "left": 0.26, "top": 0.35, "width": 0.46, "height": 0.52 } }
  ],
  "model_version": "sr-recog-1"
}
```

A photo with zero usable faces is still a successful, charged result. Billing is per photo processed, never per face. See [Billing](/docs/billing).

### Search with a selfie

Search the collection with a different photo of the same person. You get the matching `photo_id`s back, ranked by `score` (cosine similarity, 0 to 1). **Billable: 93 credits.**

_curl_
```bash
curl -X POST "$SR_BASE/v1/collections/quickstart-demo/search" \
  -H "Authorization: Bearer $SIGHTRADAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/selfie.jpg", "limit": 10}'
```

_Python_
```python
result = sr.search("quickstart-demo", url="https://example.com/selfie.jpg", limit=10)
for m in result.matches:
    print(m.photo_id, round(m.score, 3))
```

_Node_
```ts
const result = await sr.search("quickstart-demo", { url: "https://example.com/selfie.jpg", limit: 10 });
for (const m of result.matches) console.log(m.photo_id, m.score);
```

```json title="200 response"
{
  "collection_id": "quickstart-demo",
  "matches": [{ "photo_id": "photo-001", "score": 0.91 }],
  "photo_ids": ["photo-001"],
  "model_version": "sr-recog-1"
}
```

No face in the selfie? You get `"reason": "no_face"` with an empty match list. That is a successful, charged call, because the model processed the image. Only engine failures (`502`) are refunded. See [Billing](/docs/billing#reserve-settle-refund).

### Check your wallet

Billable calls also return an `X-Credits-Remaining` header, so you can track spend inline.

```bash
curl "$SR_BASE/v1/wallet" -H "Authorization: Bearer $SIGHTRADAR_API_KEY"
```

```json title="200 response"
{ "balance_credits": 4999814 }
```

## What next

- [Bulk imports](/docs/guides/batch-and-webhooks): Index up to 1,000 photos per call with per-photo results delivered to your webhook.

- [Selfie registration](/docs/guides/selfie-registration): Register a selfie once and reuse it across searches with search-by-id, at the cheaper tier.

- [Choosing a threshold](/docs/guides/thresholds): Turn a 0 to 1 similarity score into accept, review, and reject bands.

- [Auto-recharge](/docs/billing): Never run out mid-batch: set a threshold and top-up amount in Billing.
