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 we 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.
Note: Use the endpoint below to access the available Open API specifications
GET: https://api.hubspot.com/api-catalog-public/v1/apis
Language |
Package Link |
|
---|---|---|
|
||
PHP |
||
Ruby |
||
Python |
In order to start using these client libraries you'll need a HubSpot account. This will allow you to grab an API key from the account authenticate your calls. You may want to create a HubSpot developer account and use OAuth to authenticate your calls.
Example using Node.js:
Install
npm install @hubspot/api-client
Instantiate client
//Authenticate via API Key
const hubspot = require('@hubspot/api-client')
const hubspotClient = new hubspot.Client({ apiKey: YOUR_API_KEY })
//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)
})