@nylon/sdk is a typed client over the same REST API these docs describe. It has no runtime dependencies, and its types are generated from Nylon’s OpenAPI specification, so they cannot drift from the API.
Your first post
apiKey defaults to process.env.NYLON_API_KEY, so new Nylon() is enough when that is set.
What the SDK adds over fetch
Everything here is reachable with raw HTTP — these are the parts that are easy to get wrong by hand.
Retries that cannot double-post
Retries that cannot double-post
posts.create generates an idempotency_key for you, so a retry after a network blip returns the original post instead of publishing a second time. Retries use exponential backoff with full jitter and honour Retry-After.Supply your own key when the natural one lives in your system, so your retries collapse too:Typed errors
Typed errors
Branch with One class per error code, plus
instanceof rather than on a string. code is stable; message is for humans.NylonConnectionError and NylonTimeoutError for requests that never arrived.Webhook verification
Webhook verification
verifyWebhook signs the raw body, checks the timestamp against a 5-minute tolerance, and compares in constant time — the three things hand-rolled verification usually gets wrong. It is a pure WebCrypto function, so it needs no API key and runs on every supported runtime.Lazy pagination
Lazy pagination
listAll fetches each page only as you consume it, so a large account holds one page in memory rather than all of it. Breaking out stops the requests.Resources
Handling a partial failure
A post to four profiles is four independent attempts, and three succeeding while one fails is a normal outcome. Retry only the failed targets — re-sending the whole post would publish it twice on the ones that already worked.Configuration
AbortSignal:
Types
Every schema is exported, generated from the OpenAPI specification:paths, components and operations are exported too, for reaching past the SDK.
Next
Quickstart
The same first steps in raw HTTP.
API reference
Every endpoint the SDK wraps.
Errors
The error taxonomy behind the typed classes.
Webhooks
Payloads, retries and signature verification.