Generate an SDK
Choose a target, download its files, authenticate, and run an operation.
SDK generation reads the current Backend delivery schema through the authenticated management plane. The downloaded files call the separate Delivery API and grant no access by themselves.
Access
Generation requires delivery.readSdk with Backend scope. Human Admin operations also require visibility of that Backend. Runtime calls require a separate key with delivery.readPublished or delivery.readPreview, scoped to the Backend.
Generate files
- Open the Backend’s API area.
- Choose a target and its options.
- Generate and inspect the filename/content preview.
- Download one file or the ZIP.
- Install the packages shown for the selected target and configure the Delivery GraphQL URL and
x-api-key.
| Group | Targets |
|---|---|
| TypeScript/JS clients | Client Preset, graphql-request SDK, TypedDocumentNode, React Query, React Apollo, urql (React), Vue urql, Vue Apollo, Angular Apollo |
| Schema types | TypeScript types, Java, Kotlin, C#, Flow |
| Other operations | C# operations, Flow operations |
Run a generated client
For the graphql-request target, the generated SDK can be configured like this:
import { GraphQLClient } from 'graphql-request';
import { getSdk } from './sdk';
const sdk = getSdk(
new GraphQLClient('https://delivery.example.com/graphql', {
headers: { 'x-api-key': process.env.JETREPO_DELIVERY_KEY! },
}),
);
const { article } = await sdk.GetArticle({ id: 'ARTICLE_ID' });
article is illustrative and exists only when the Backend model defines that key.
Default generated operations provide Get/List for non-Asset Content types. Selections expand at most two nested levels, include named image-style aliases, and include HTML siblings for renderable LongText fields. Assets are reached through fields in these defaults.
Regenerate after model or image-style changes. Edit generated default operations when a consumer needs a different selection; generation does not promise to cover every valid query.