@tokens-studio/sdk

Token Studio SDK

This is the official SDK for Tokens Studio.

View technical diagram which we created to showcase how the SDK & CLI work, how to create an API key, and how you can use the GraphQL Apollo Sandbox environment to play around with our API and run regular HTTP requests against it to query or mutate data.

npm install @tokens-studio/sdk

See help menu for usage of the CLI.

npx tokensstudio --help
npx tokensstudio setup --help
npx tokensstudio pull --help

Example pulling tokens into local filesystem, after having created and filled a .tokensstudio.json file in the current working directory through the setup command:

TOKENS_STUDIO_API_KEY=your_api_key npx tokensstudio setup
TOKENS_STUDIO_API_KEY=your_api_key npx tokensstudio pull

Note: if you don't pass an environment variable for the API key, the CLI will prompt you for it instead.

Which will pull the tokens from your configured org, project and branch, assuming the API key has read permissions to the tokensets in that project.

{
"version": "2",
"org": "1f15691a-1d96-4049-bd53-943c869ce827",
"project": "bd5e89d5-96f3-441a-bf9c-6041d5eccebc",
"branch": "main",
"release": "",
"output": "tokens"
}

release is optional and WIP for now. Once we have releases, you can specify it so it can pull the release artifacts for you.

For Studio devs that run the Studio App backend locally:

TOKENS_STUDIO_API_KEY=api_key_test npx tokensstudio pull --host localhost:4200 --insecure

If your API key was created through seeding rather than in the frontend app itself, ensure you associate the key with the correct user in the database (e.g through Prisma Studio).

When running tests, ensure that you run the build step first because the tests run the compiled CLI directly as a way to test end to end.

See the documentation for the GraphQL API here.

See the documentation site for more info.

This library is ESM by default. We do not compile to CommonJS.

The entire library is built with TypeScript and provides multiple utilities to ensure type safety.

This repository is published under the MIT license.