Client Libraries

Client libraries are designed to help you interact with the HubSpot APIs with less friction.  They are written in several different languages and help bridge the gap between your application and HubSpot’s APIs. They take away the need to know the exact URL and HTTP method to use for each API call among other things leaving you more time to focus on making your application.

Starting from the source code that powers the HubSpot application, HubSpot generate documents that describe our APIs using the Open API format. Those documents are fed into the Open API code generator, these generated files end up in the libraries, but this isn’t the end of the story. A team of developers at HubSpot take the output of this code generation and add more value to it by adding utility functions to help with things like rate limiting as well as number of example applications to show how to use the libraries in practice. These examples cover a wide range of use cases so be sure to take advantage of them.

Use the endpoint below to access the available Open API specifications

GET: https://api.hubspot.com/api-catalog-public/v1/apis

 

          Language

Package Link

githubSource Code

iconfinder_nodejs-512_339733Node.js

npm install @hubspot/api-client

hubspot-api-nodejs

new-php-logo

PHP

composer require hubspot/api-client

hubspot-api-php

ruby

Ruby

gem install hubspot-api-client

hubspot-api-ruby

iconfinder_267_Python_logo_4375050

Python

pip install hubspot-api-client

hubspot-api-python

Get started

To start using these client libraries, you'll need a HubSpot account, either a standard account or an app developer account.  This will enable you to create a private app so that you can use the private app token to authenticate your calls. You can also create a HubSpot developer account and use OAuth to authenticate your calls.

Once you have a HubSpot account and a private app access token or OAuth token, you can install the library. Below, see an example of installing the Node.JS client, instantiating the client, and general usage.

Install 

npm install @hubspot/api-client

Instantiate client

//Authenticate via private app access token stored as a secret const hubspot = require('@hubspot/api-client') const hubspotClient = new hubspot.Client({ accessToken: process.env.secretName }) //Or via OAuth const hubspotClient = new hubspot.Client({ accessToken: YOUR_ACCESS_TOKEN })

Usage

//Example call hubspotClient.crm.contacts.basicApi .getPage(limit, after, properties, associations, archived) .then((results) => { console.log(results.body) }) .catch((err) => { console.error(err) })

Was this article helpful?
This form is used for documentation feedback only. Learn how to get help with HubSpot.