copilot-node-sdk
v3.5.0
Published
The Copilot.com Node.JS SDK
Downloads
1,041
Readme
Copilot Node.JS SDK
The Copilot Node.JS SDK provides easy to call functions written in TypeScript for interacting with the Copilot REST API. Right now this is a TypeScript only package. In the future we will have a Vanilla JS package with a corresponding @types package to go along with it.
This SDK is intended to be used on the server-side only. We do not currently offer a package for client-side development.
Setup
For Custom Apps
import { copilotApi } from 'copilot-node-sdk';
const copilot = copilotApi({ apiKey: YOUR_API_KEY_HERE });
For Marketplace Apps
If you're building a Marketplace app you should go through one additional step of fetching a query parameter that gets passed into the App URL when rendered in the Copilot dashboard: ?token=TOKEN_IS_HERE
Grab that token from the URL and pass it in to the copilotApi configuration object.
import { copilotApi } from 'copilot-node-sdk';
const copilot = copilotApi({
apiKey: YOUR_API_KEY_HERE,
token: searchParams.token,
});
How to develop this package internally:
yarn
yarn generate-api
yarn test
to produce a successful responseyarn test:fail
to product a response that fails because of a missing env variable.
For additional logging you can set the environment variable COPILOT_DEBUG
to any truthy value. This is useful if you'd like to see SDK logs while developing in an application's codebase.