@builder.io/admin-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

Builder.io Admin API SDK.

Nodejs SDK to interact with Builder.io Graphql Admin API (beta).

How to use

  • Install using your favorite package manager:
npm install @builder.io/admin-sdk
  • get a private key of the space you want to administer bpk-xxx
import { createAdminApiClient } from '@builder.io/admin-sdk';
const adminSDK = createAdminApiClient(process.env.BUILDER_PRIVATE_KEY);

// example getting space settings:
const res = await adminSDK.query({
  settings: true,
});

// example getting all models fields on a space:
const res = await adminSDK.query({
  models: {
    id: true,
    fields: true,
  },
});

// example creating a model from admin api
await adminSDK.chain.mutation
  .addModel({
    body: {
      defaultQuery: [],
      kind: 'component',
      showTargeting: true,
      allowHeatmap: true,
      id: 'xxxxxx',
      showMetrics: true,
      publicReadable: true,
      name: 'announcement-bar',
      useQueryParamTargetingClientSide: false,
      fields: [
        {
          type: 'uiBlocks',
          '@type': '@builder.io/core:Field',
          required: true,
          hideFromFieldsEditor: true,
          name: 'blocks',
          showTemplatePicker: true,
        },
      ],
      helperText: 'This model is for announcement bars',
      allowBuiltInComponents: true,
      bigData: false,
      strictPrivateWrite: false,
      requiredTargets: [],
      schema: {},
      examplePageUrl: 'https://my.site.com/preview',
      webhooks: [],
      apiGenerated: true,
      showScheduling: true,
      showAbTests: true,
      pathPrefix: '/',
      componentsOnlyMode: false,
    },
  })
  .execute({});

More info:

  • check the graphiql explorer on beta.builder.io/api/v2/admin, add your private key to the http headers section and inspect available queries / mutations:

BUILDER

Readme

Keywords

Package Sidebar

Install

npm i @builder.io/admin-sdk

Weekly Downloads

922

Version

0.0.5

License

MIT

Unpacked Size

66.3 kB

Total Files

10

Last publish

Collaborators

  • harmeet.builder
  • armela
  • strd6
  • murtaza-haveliwala
  • gustavohgs
  • sanyamkamat
  • shyam-builder
  • manucorporat
  • steve8708
  • samijaber
  • caleb.amsden
  • teleaziz123
  • mrkoreye
  • mhevery
  • adamdbradley