for developers

Three ways to build against ScreenCaster, in increasing order of what they cost and what they give you.

Why there is no “give my app screen sharing” call. Whole-screen capture on iOS happens in a broadcast upload extension, and the extension must live in the capturing app’s own bundle, signed with that app’s team. That capability cannot be lent across an app boundary — no URL scheme and no server endpoint can put ScreenCaster’s capture inside your process. A link hands the user over; the kit puts capture in your app and you ship the extension yourself, the way every other streaming SDK does.

The cheapest useful integration. Your app opens a screencaster:// URL; ScreenCaster does the thing and opens a URL of yours with the answer.

Asking

screencaster://cast[?return=<address>][&state=<opaque>]
screencaster://join?code=ABC234[&return=<address>][&state=<opaque>]
return Where to answer. A bare scheme (partnerapp) or a full URL (partnerapp://oauth/callback). Optional — without it the handoff is one-way.
state Echoed back verbatim, up to 512 characters. Match an answer to whatever you were doing when you asked.

Being answered

partnerapp://screencaster?status=ready&code=ABC234&link=https%3A%2F%2F…&state=…
partnerapp://screencaster?status=declined&state=…
partnerapp://screencaster?status=unavailable&reason=…&state=…
ready The user agreed. code joins the session now; link is the same session as a shareable web invite.
declined The user was asked and said no. Do not retry.
unavailable We could not. reason says why; retrying may work.

There is deliberately no started. iOS suspends the presenter’s app for the whole of their own broadcast, so the moment frames begin flowing is a moment at which ScreenCaster is not running and could not open a URL if it were. ready says the thing that is both true and useful: the session exists, join it, and frames arrive when the presenter starts.

What the user sees

A cast request with a return address is not answered immediately. The user lands on the Share screen with a prompt naming your URL scheme, and nothing is sent until they agree — because the session code is also the key, so handing it over hands over the cast. A join request is answered at once and without a prompt, since the only thing that answer carries is the code you supplied.

Return addresses that are refused

http: https: The answer carries key material in a query string. Sent to a web server it lands in that server’s access log, and in the log of whatever terminates TLS in front of it.
screencaster:Answering ourselves is a loop.
javascript: data: file: about: blob: Not addresses of an app. Addresses of an interpreter.
Any #fragment The answer is appended as query items, which a fragment would strand behind it.
Any user:password@ Either a mistake, or an attempt to make a URL read as something it is not.

A refused address is dropped while the request survives — the user still asked to cast, and failing the whole link leaves them staring at an app that did nothing.

The kit

ScreenCasterKit is the wire protocol, the crypto, the transports, the H.264 path and the WebRTC engines. Linking it puts casting inside your app; it does not remove the need for your own broadcast extension.

Build an XCFramework — iOS device, iOS Simulator and macOS slices, each with a .swiftinterface so it imports into an Xcode whose Swift version does not match the one that built it:

tools/build-xcframework.sh [output-directory]

The iOS slices link WebRTC and do not contain it; add github.com/stasel/WebRTC alongside. The macOS slice has no such dependency.

The App Group is the thing integrations get wrong

It is the only channel between your app and your extension, and the app cannot tell the extension at runtime — the extension is started by the system, and by then the app is suspended. So it is declared statically, in both bundles:

<key>SCRAppGroupIdentifier</key>
<string>group.com.yourcompany.yourapp</string>

plus the matching com.apple.security.application-groups entitlement on both targets. Then check it early:

guard AppGroup.isAvailable else { /* misconfigured — say so now */ }

False is conclusive; true is not. On a device, an identifier you hold no entitlement for has no container. The Simulator does not gate containers on the entitlement at all, so every well-formed identifier resolves there. Check on hardware before believing it.

The partner API

For giving your users casting on this relay, with your own keys, quotas and metered billing.

Base URL   https://screencaster.co/v1
Auth       x-api-key: <your key>
Send the room id, never the session code. The six-character code is what both devices derive their AES-GCM key from, so this server must never see it. Your device derives a 32-character hex room id from the code and sends that. The relay cannot map it back, which is the point.

Endpoints

GET /v1/config Your terms and this relay’s endpoints — relay_url, ice_url, web_viewer_base.
POST /v1/sessions Authorise one cast. Returns the session, a sender and a viewer token, and what it will cost.
GET /v1/sessionsYour sessions, live and recently ended.
GET /v1/sessions/{id}One session. Someone else’s reports as missing, not forbidden, so ids cannot be probed.
POST /v1/sessions/{id}/endEnd and settle it. DELETE /v1/sessions/{id} does the same.
GET /v1/usageBalance, live sessions and minutes, credits held, and anything that could not be billed.
POST /v1/checkout{ "credits": 500 } — a hosted checkout URL to top up.

Starting a cast

POST /v1/sessions
x-api-key: <your key>

{
  "room": "3f2a…",                       // 32 hex, derived on the device
  "end_user": { "id": "u_123", "email": "user@example.com" },
  "estimated_minutes": 30,
  "metadata": { "ticket": "SUP-4417" }
}
201 Created

{
  "session": { "id": "…", "state": "live", … },
  "tokens": {
    "sender": "…", "viewer": "…",
    "expires_at": "2026-08-28T20:00:00.000Z"
  },
  "relay_url": "wss://screencaster.co",
  "ice_url":   "https://screencaster.co/ice",
  "web_viewer_base": "https://screencaster.co/j/",
  "billing": {
    "credits_per_minute": 2,
    "free_minutes_per_session": 0,
    "credits_held": 60,
    "rounding": "each session is rounded up to the next whole minute"
  }
}

Hand the tokens to the devices. They connect with the token on the socket:

wss://screencaster.co/ws?room=<32 hex>&role=sender|viewer|participant&token=<token>

A room you reserved refuses a sender or participant that presents no token — otherwise a device could omit its token and cast for free, or claim the presenter role and close the sender you are paying for. A viewer without a token is admitted: viewers are free, they receive only ciphertext they cannot open without the session code, and the invite link you send has never carried a token. A room nobody reserved needs none, which is how the first-party apps keep working.

Billing

Metered per minute against cred.diy credits, as hold-then-capture, because nobody knows what a cast costs until it stops:

authorise → hold(estimate) → …cast runs… → capture(actual)

The difference is released, so reserving an hour and casting four minutes pays for four. Two API calls per session whatever its length. Four rules:

Electrum. When it is on, a session your own credits cannot cover is held in full on the shared Electrum wallet of your billing email instead — never split across the two — converted at your credit's Electrum rate (1 Electrum = $1), and settled there. GET /v1/usage then shows it beside your credits as balance.aw3 (Electrum, two decimals, never added to credits). This relay never sells Electrum; it is bought on ZeusMCP.

Sessions round up to the whole minute: a nine-second cast bills one, because a per-second price on a thing that reconnects is a price nobody can predict.

Errors

Every failure is JSON with an error and a stable code.

401 UNAUTHORIZEDMissing or unknown x-api-key.
402 INSUFFICIENT_CREDITSYou are out. Carries your balance, what was needed, a top_up_url for your own credits and, while Electrum is on, an electrum_url.
404 NOT_FOUNDNo such route, or a session that is not yours.
409 ROOM_IN_USEThat room already has a live session. End it, or use a new session code.
429 CONCURRENCY_LIMITToo many sessions live at once for your terms.
429 RATE_LIMITEDToo many API requests.
503 PARTNER_API_DISABLEDThis relay has no partner API enabled.
503 BILLING_UNAVAILABLEBilling is not configured, or our own balance is empty.

Getting a key

Keys are issued per partner, with a rate, a free allowance, a maximum session length and a concurrency ceiling. Only a digest is stored, so a key that is lost is replaced rather than recovered. Ask for one.