@socialrouter/sdk package provides a typed client for the SocialRouter API. It handles authentication and error mapping, and types every call against the live service catalogue.
Installation
Quick example
What’s included
run(service, input): one generic entry point, typed per service- Typed per-service methods, grouped by platform:
sr.reddit.subredditPosts({ … }) - Correlated input types: a URL service takes
url/urls, a query service takesquery/queries, and mixing them is a compile error - Typed options per service:
options: { sort: "top" }onreddit/subreddit.posts, and a compile error on a service that declares none - Catalogue access:
listServices(),getService(),listSources() - Error classes per HTTP status (
AuthenticationError,InsufficientCreditsError,RateLimitError) - Uses native
fetch(), so Node.js 18+ is required
Typed methods
sr.reddit.subredditPosts(input) and sr.run("reddit/subreddit.posts", input) are the same call.
Next steps
Client reference
All methods, parameters, and return types.
Error handling
Error classes and how to handle failures.