npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

zendesk-node

v0.8.2

Published

Node Wrapper for Zendesk V2 API

Downloads

1,972

Readme

Zendesk NodeJS SDK

The Zendesk NodeJS SDK provides a wrapper around the Zendesk V2 REST JSON API.

Documentation for the API can be found at: https://developer.zendesk.com/rest_api/docs/zendesk-apis/resources

The Zendesk API is rate limited. To see how many requests per minute is allowed please refer to Zendesk's documentation here.

https://developer.zendesk.com/rest_api/docs/support/introduction#rate-limits

Zendesk Resources are declared under lib/resources/**.js, and will be injected into the lib/api/index.js object, which is then exported from lib/index.js.

Requirements

  • Node.js v8 (may work with previous versions but not supported)

Installation

yarn add zendesk-node

Libraries used

Creating an API Object

You must be a verified user to make API requests. You can authorize against the API using either basic authentication with your email address and password, with your email address and an API token, or with an OAuth access token. - Zendesk Documentation

Basic authentication

If an agent or admin has enabled 2-factor authentication in their user profile, they won't be able to use basic authentication. Alternatives include using an API token or implementing an OAuth flow. Learn more. - Zendesk Documentation

const Zendesk = require('zendesk-node');

const email = 'AGENT_S_EMAIL_ADDRESS';
const password = 'AGENT_S_PASSWORD';
const zendeskSubdomain = 'ZENDESK_SUBDOMAIN';
const zendesk = Zendesk({ authType: Zendesk.AUTH_TYPES.BASIC_AUTH, zendeskSubdomain, email, password });

API token

const Zendesk = require('zendesk-node');

const email = 'AGENT_S_EMAIL_ADDRESS';
const zendeskSubdomain = 'ZENDESK_SUBDOMAIN';
const zendeskAdminToken = 'API_TOKEN'; // Login to your Zendesk's Agent and go to Admin -> API to generate.
const zendesk = Zendesk({ authType: Zendesk.AUTH_TYPES.API_TOKEN, zendeskSubdomain, email, zendeskAdminToken });

Oauth access token

Currently the API expects that you have curled your own admin token.

const Zendesk = require('zendesk-node');

const zendeskSubdomain = 'ZENDESK_SUBDOMAIN';
const zendeskAdminToken = 'OAUTH_ACCESS_TOKEN';
const zendesk = Zendesk({ authType: Zendesk.AUTH_TYPES.OAUTH_ACCESS_TOKEN, zendeskSubdomain, zendeskAdminToken });

Note: if authType is omitted the sdk defaults to oauth access token method.

Querying the API

CRUD actions should follow a common interface.

Notes:

  • queryParams and body values can be provided in camelCase, and will be serialised into snake_case as the API expects.
  • GET requests to the Zendesk API expect Array values to be provided as comma separated values. The package will transform any Array values that are passed into a queryParams object at time. Ie, { ids: [1, 2, 3] } will become ?ids=1,2,3
  • List data is auto-sorted by most recently created.

GET

const ticket = await zendesk.tickets.get(42, { /* GET params */ });

LIST

const tickets = await zendesk.tickets.list({ /* GET params */ });

CREATE

const ticket = await zendesk.tickets.create({/* POST data */});

CREATE MANY

const ticket = await zendesk.tickets.createMany({/* POST data */});

UPDATE

const ticket = await zendesk.tickets.update(42, {/* POST data */});

DELETE

await zendesk.tickets.delete(42);

Supported Resources

The Zendesk API is large, and not all API resources have been implemented yet.

Currently supported resources include:

Tickets

Views

Ticket comments

User identities

Search

Users

Groups

Group Memberships

  • List Memberships: zendesk.groupMemberships.list(queryParams), zendesk.groupMemberships.listByUser(userId, queryParams), zendesk.groupMemberships.listByGroup(groupId, queryParams)
  • List Assignable Memberships zendesk.groupMemberships.listAssignables(queryParams), zendesk.groupMemberships.listAssignablesByGroup(groupId, queryParams)
  • Show Membership: zendesk.groupMemberships.get(id, queryParams), zendesk.groupMemberships.getByUser(userId, id, queryParams)
  • Create Membership: zendesk.groupMemberships.create(body)
  • Delete Membership: zendesk.groupMemberships.delete(id), zendesk.groupMemberships.deleteByUser(userId, id)
  • Set Membership as Default: zendesk.groupMemberships.setAsDefault(userId, membershipId, body)

Tags

  ENTITY_TYPES = {
    organization: 'organizations',
    ticket: 'tickets',
    user: 'users',
  };