Important
This will explain how to use our provided operations and their types to start working with the api
For now, all the exported types will correspond to the 2024-04 version, with no regard to the version you specify
If you need a different version OR When you'l want to write your own TYPED queries, you have two options:
- If you aren't a monday app developer, use @mondaydotcomorg/setup-api
- If you are a monday app developer, use @mondaydotcomorg/apps-cli in your app root directory, and choose the api:generate option
Monday GraphQL JS SDK
This SDK provides you with an easy way to interact with monday.com's GraphQL API.
The SDK is supported in both Node.js and browser environments, and is using the graphql-request client under the hood.
Installation
npm install @mondaydotcomorg/api
Usage
Using the api client
The package exports the class ApiClient
which is the main entry point to the SDK. You can use it to query monday's API freestyle, or use the operations provided by the SDK.
import { ApiClient } from '@mondaydotcomorg/api';
const client = new ApiClient('<API-TOKEN>');
const me = await client.operations.getMeOp();
const changeTextColumn = await client.operations.changeColumnValueOp({
boardId: "your_board_id",
itemId: "your_item_id",
columnId: "text",
value: JSON.stringify("Hello, world!"),
});
const changeStatusColumn = await client.operations.changeColumnValueOp({
boardId: "your_board_id",
itemId: "your_item_id",
columnId: "project_status",
value: JSON.stringify({ label: "Done" }),
});
const boards = await client.query<{boards: [{ name: string }]}>(`query { boards(ids: some_id) { name } }`);
const { boards } = await client.query<{
boards: [Board];
}>(`query { boards(ids: some_id) { name } }`);
Using the types
The package exports all the types used by the SDK, so you can use them in your code.
import { User } from '@mondaydotcomorg/api';
const user: User = {
id: '123',
name: 'John Doe',
email: 'john.doe@someorg.com'
}