UNPKG

monday-api-client

Version:

Easy to use client for talking to the Monday.com API.

109 lines (88 loc) 3.06 kB
# node-monday-api-client Created by: https://www.enable.services/ Package allows you to easily * Retrieve a pulse with a boardId and a pulseId * Mutate a pulse with a boardId and a pulseId * Query a column with a boardId, columnId and a column value * Create a pulse with a boardId, group and an object of column values * Retrieve all the pulses and pulse data in a group with a boardId and groupId * Send a notification to monday with a userId and a boardId * Get basic user data with a userId * Get all users id, name and email ## Installation ```bash npm i monday-api-client ``` ## Usage ```javascript mondayApi = require('monday-api-client'); //You can either pass in the boardId and the pulseID manually const data = {boardId : 123456, pulseId: 654321}; //Or //You can use the event object within req.body, which come's from the monday.com webhook const data = JSON.parse(req.body.event); const token = 'My v2 api token'; ``` ```javascript //Returns a callback with the pulseData mondayApi.pulse.getData(data, token, pulseData => { console.log(pulseData); }); ``` ```javascript //The column object must contain the name of the column and the new value for that column under the pulseId provided //For more info on the values, please goto https://monday.com/developers/v2#column-values-section-status data.columnObj = {name: 'status', value: `"{\\"label\\":\\"Stuck\\"}"`}; //The data object requires a boardId, a pulseId and a column object //Mutates an item column and returns the pulse id mondayApi.pulse.mutate(data, token, pulseData => { console.log(pulseData); }); ``` ```javascript const columnQueryData = {boardId, columnId, columnVal}; mondayApi.pulse.queryColumn(columnQueryData, token, pulseData => { console.log(pulseData); }); ``` ```javascript //Send a notification to Monday with a userId, boardId, message and token mondayApi.notification .sendProject( {userId: 16101106, boardId: 749698622}, '"Message!"', token ); ``` ```javascript //You can grab all the pulse data under either just one or multiple groupIds //GroupIds can either just take a string of one id or an array of group ids mondayApi.group.getPulseData({boardId: "622641507", groupIds: ["group_title", "new_group"]}, token, pulseData => { console.log(JSON.stringify(pulseData)); }); ``` ```javascript userIds can be just a string of just one userId or an array of userIds mondayApi.user.getBasicData(userIds, token, userData => { console.log(JSON.stringify(userData)); }); ``` ```javascript let mondayData ={ "name" : "George", "person" : {"personsAndTeams":[{"id":13983951, "kind":"person"}]}, "text": "Devloper", }; const details = {boardId: 123456789, groupId: "group1"}; mondayApi.pulse.create(details, mondayData, token, users => { console.log(JSON.stringify(users)); }); ``` ```javascript mondayApi.user.getAll(token, users => { console.log(JSON.stringify(users)); }); ``` ## Extra info This package depends on esm and monday-sdk-js. Make sure you install the latest version!