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

node-calendly

v1.0.10

Published

Node module to access calendly api.

Downloads

1,076

Readme

Calendly API Node.js

Calendly API bindings for Node.js

Installation

$ npm install --save node-calendly

API

The API is accessed by a central object that constructs the endpoints to the Calendly API.

This module implements the Calendly API v2.0.0: https://developer.calendly.com/api-docs/d7755e2f9e5fe-calendly-api

Calendly(ACCESS_TOKEN:string)

Creates a new Calendly instance. NOTE: Currently only personal access tokens are implemented, used for internal applications.

Arguments

  • ACCESS_TOKEN - Required - A string containing the ACCESS_TOKEN for Calendly. You can create your private ACCESS_TOKEN via Calendly web site. See https://developer.calendly.com/getting-started

Return value

A Calendly instance.

Example

import Calendly from 'node-calendly';

const calendly: Calendly = new Calendly(CALENDLY_ACCESS_TOKEN);

API call limits

No Calendly call limits known and implemented.

API endpoints

Every endpoint is accessed via your node-calendlyinstance:

const calendly: Calendly = new Calendly(CALENDLY_ACCESS_TOKEN);

// calendly.<endpoint_name>.<method_name>

Each endpoint returns a Promisethat resolves with the result:

calendly.users
    .getUser({ uuid: 'user-uuid' })
    .then((user) => console.log('user:', user))
    .catch((err) => console.error(err));

async/await can also be used:

try {
    const user : User = await calendly.users.getUser({ uuid: 'user-uuid' });
    console.log('user:', user))
} catch(err){
    console.error(err)
};

The Calendly API requires that you send a valid JSON string in the request body or request parameters. For example, the request parameters to List Events should be:

    https://api-endpoint/?count=20&sort=asc

When using the module node-calendly you don't have to specify the full request path as the module automatically wraps the provided data. Using the above example this translates to:

calendly.scheduledEvents
    .listEvents({
        count: 20,
        sort: 'asc'
    })
    .then((events) => console.log('events:', events))
    .catch((error) => console.error('error:', error));

Similarly, the Calendly API returns different response body information like pagination and collection.

The module node-calendly automatically unwraps the parsed object and returns:

{
    "collection": [
        {
            "uri": "uri",
            "name": "30 mins initial call",
            "location": {
                "type": "outbound_call",
                "location": "+1123456789"
            }
            ...
        }
    ],
    "pagination": {
        "count": 200,
        "next_page": "next page"
        ...
    }
}

This behaviour is valid for all resources.

Pagination

Also referred to as "cursor-based pagination", this approach is how calendly handles pagination for all API endpoints that can return a collection of multiple resources. Unlike offset-limit pagination, this approach allows to provide accurate data to users, despite resources possibly being added/removed to the collection on subsequent page retrievals.

When calling an endpoint that returns a collection of multiple resources, you will have a pagination object in the response. Inside of the pagination object is a next_page attribute. If there are more resources than what has been returned, the next_page attribute will contain the URL to the next page of resources; otherwise, next_page will be null:

Pagination in Calendly API version v2.0.0 and above can be done as shown in the following example:

(async () => {
    calendly.getOrganizationUri().then(async (uri) => {
        let nextPageToken;

        do {
            const events: PaginationResponse<EventType> =
                await calendly.scheduledEvents.listEvents({
                    organization: uri,
                    page_token: nextPageToken,
                    count: 100
                });
            console.log(events.collection);
            if (events) {
                nextPageToken = events.pagination.next_page_token;
            }
        } while (nextPageToken);
    });
})().catch(console.error);

Each set of results have the nextPageToken and previous_page_token properties. These properties specify respectively the parameters needed to fetch the next and previous page of results.

Available API endpoints and methods

  • activityLog : ActivityLog
    • listActivityLogEntries(params: ActivityLogQueryParams) : Promise<ActivityLogResponse>
  • dataCompliance : DataCompliance
    • deleteInviteeData(emails: string[]): Promise<DataComplianceResponse>
  • eventTypes: EventTypes
    • listUsersEventTypes(params: EventTypeUserRequest): Promise<PaginationResponse<EventType>> If user is not specified in params, the current user is used.
    • listOrganisationEventTypes(params: EventTypeOrganisationRequest): Promise<PaginationResponse<EventType>> If organization is not specified, the current organization is used.
    • getEventType({ uuid }: { uuid: string }): Promise<EventType>
    • listEventAvailableTimes(params: EventTypeAvailableTimeRequest): Promise<EventTypeAvailableTimeResponse>
  • scheduledEvents: ScheduledEvents
    • listEvents(params: ListEventsRequestParams): Promise<PaginationResponse<EventDefinition>>
    • listEventInvitees(uuid: string,params: ListEventInviteesRequestParams): Promise<PaginationResponse<Invitee> & ErrorResponse>
  • users: Users
    • getCurrentUser(): Promise<User>
    • getUser(params: UserQueryParameters): Promise<User>

Currently unimplemented API andpoints and methods

  • scheduledEvents: ScheduledEvents

    • getEventInvitee
    • getEvent
    • getInviteeNoShow
    • deleteInviteeNoShow
    • createInviteeNoShow -cancelEvent
  • Organizations

  • Routing Forms

  • Scheduling Links

  • Webhooks

  • OAuth 2.0

License

MIT