# SDKs and packages (/docs/api/sdks)

Use the official TypeScript SDK, Effect v4 SDK, 2D replay embed controller, webhook verifier, and self-hosted overlay SDK.

Strave publishes focused packages for TypeScript and Effect v4 applications.
They handle OIDC Trusted Workload token exchange, `Idempotency-Key` headers,
strong `If-Match` revision tags, cursor pagination, live SSE streams, webhook
verification, and hosted 2D replay embeds.

## Install `@strave/sdk` [#install-stravesdk]

```sh
bun add @strave/sdk
```

For Effect v4 projects, also install `effect` v4:

```sh
bun add @strave/sdk effect
```

## Plain TypeScript client [#plain-typescript-client]

The root entry point (`@strave/sdk`) has zero runtime dependencies and runs in
Node.js, Bun, Cloudflare Workers, and browsers. Use `oidcWorkload` in production
so your servers authenticate with short-lived OIDC tokens instead of static
secrets, or start with `sandbox: true` at zero cost:

```ts
import { createStraveClient, paginate } from "@strave/sdk";
import { getVercelOidcToken } from "@vercel/oidc";

const strave = createStraveClient({
	oidcWorkload: {
		clientId: process.env.STRAVE_CLIENT_ID!,
		getAssertion: () =>
			getVercelOidcToken({ audience: "https://strave.gg/api/auth" }),
		scopes: ["event:read"],
	},
});

const { data: event, etag } = await strave.events.get("event_01K4ZK");

for await (const match of paginate((cursor) =>
	strave.events.listMatches(event.id, { cursor }),
)) {
	console.log(match.id, match.status, etag);
}
```

## Effect v4 client [#effect-v4-client]

`@strave/sdk/effect` provides a `Context.Service` tag (`StraveClient`),
`StraveClient.layer`, `StraveClient.sandboxLayer`, `StraveClient.layerFromEnv`,
typed `Schema.TaggedError` failures, and Effect `Stream` consumers:

```ts
import { StraveClient } from "@strave/sdk/effect";
import { Effect, Stream } from "effect";

const program = Effect.gen(function* () {
	const strave = yield* StraveClient;
	const { data: event } = yield* strave.events.get("event_sbx_eml_s7");

	yield* strave
		.streamEvent(event.id)
		.pipe(Stream.runForEach((frame) => Effect.logInfo(frame.type)));
}).pipe(Effect.provide(StraveClient.sandboxLayer()));
```

## Verify webhooks [#verify-webhooks]

`@strave/sdk/webhooks` verifies `strave-webhook-signature` headers with Web
Crypto HMAC SHA-256 and constant-time comparison:

```ts
import { createWebhookHandler } from "@strave/sdk/webhooks";

export const POST = createWebhookHandler({
	secret: process.env.STRAVE_WEBHOOK_SECRET!,
	onEvent: async ({ deliveryId, event }) => {
		console.log(deliveryId, event.type, event.data.resourceId);
	},
});
```

## Control 2D replay embeds with `@strave/replay-embed` [#control-2d-replay-embeds-with-stravereplay-embed]

`@strave/replay-embed` mounts Strave's hosted `/embed/replay` viewer and exposes
a typed `postMessage` controller with zero replay parser code or map assets.
See the [2D replay viewer guide](/docs/api/embeds/replay-viewer).

```sh
bun add @strave/replay-embed
```

## Self-hosted OBS overlays with `@strave/overlay-sdk` [#self-hosted-obs-overlays-with-straveoverlay-sdk]

Strave's managed third-party overlay hosting is not online yet. Use
`createLiveOverlaySource` in `@strave/overlay-sdk` to drive self-hosted OBS
browser sources from a backend SSE proxy today. See the
[Self-hosted OBS overlays guide](/docs/api/guides/obs-overlay).

```sh
bun add @strave/overlay-sdk
```

## Next steps [#next-steps]

- Configure zero-secret authentication with
  [OIDC Trusted Workloads](/docs/api/guides/oidc-trusted-workloads).
- Test against fixed Siege data in [Sandbox mode](/docs/api/sandbox).
- Scaffold projects and test webhooks locally with the
  [Strave CLI](/docs/api/cli).