Tags

GraphQL
SDK
API

On this page

Internal API
SDK

Internal API

Note: The internal API is not intended as the primary way to fetch content for your front-end application or website. To fetch the content of your documents, the first place to look should be the external GraphQL API. Only if you need something beyond its scope, such as writing automatic migrations or handling imports and exports of project data, should you use the internal API.

We provide a TypeScript SDK that covers all the functions we use in the caisy front-end itself, and it can also be used by external projects. This SDK is automatically generated from a GraphQL API that we provide and use internally. Furthermore, you can use the GraphQL API in any other language.

You can try it under the following URL → https://cloud.caisy.io/caisy/graphql

in any GraphQL playground you like

SDK

To use the SDK, you must install it with: yarn add @caisy/sdk

First, you need to set up the SDK with a token. The best way to do this is to create a permanent personal access token:

To init the SDK:

import { initSdk } from "@caisy/sdk";
const sdk = initSdk({
    token: token,
});

In an IDE with Typescript autocomplete support, like in Visual Studio Code, you can see all the possible queries you can make directly with the SDK.

screenshot sdk code create

Suppose you want to retrieve all the blueprints of your project. The code is as follows:

const getManyBlueprintsResult = await sdk.GetManyBlueprints({ input: { projectId: "aa0943f2-af8e-4920-afe5-96e7c6fb7b01" } });

Or you could duplicate a project using the SDK as follows:

await sdk.DuplicateToProject({
        input: {
            projectId: "b85f60bc-26c6-41cd-9a30-69f64a8ec3c3",
            source: {
                projectId: "41fcf4c7-b04b-4715-80fb-ebccfa70ac11",
            },
            selection: {
                blueprint: true,
            },
        },
    });

Side note → The same could be don with a GraphQL mutation as follows:

mutation {
  DuplicateToProject(
    input: {
      projectId: "b85f60bc-26c6-41cd-9a30-69f64a8ec3c3"
      source: { projectId: "41fcf4c7-b04b-4715-80fb-ebccfa70ac11" }
      selection: { blueprint: true }
    }
  ) {
    portId
  }
}


single caisy logo without name
caisy
Solutions
Resources
Made for you

© 2023 caisy

Tags

GraphQL
SDK
API

On this page

Internal API
SDK