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 building 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, then the generated files end up in the libraries. A team of developers at HubSpot then take the output of this code generation and adds more value to it through 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.

Use the endpoint below to access the available Open API specifications

GET http://api.hubspot.com/public/api/spec/v1/specs

 

          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. 

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.