What is @hubspot/api-client?
The @hubspot/api-client npm package is a comprehensive client library for interacting with HubSpot's APIs. It allows developers to easily integrate HubSpot's CRM, marketing, sales, and service functionalities into their applications.
What are @hubspot/api-client's main functionalities?
CRM
This feature allows you to manage CRM functionalities such as creating, reading, updating, and deleting contacts. The code sample demonstrates how to create a new contact in HubSpot.
const hubspot = require('@hubspot/api-client');
const hubspotClient = new hubspot.Client({ apiKey: 'your-api-key' });
async function createContact() {
const contactObj = { properties: { firstname: 'John', lastname: 'Doe', email: 'john.doe@example.com' } };
const createResponse = await hubspotClient.crm.contacts.basicApi.create(contactObj);
console.log(createResponse);
}
createContact();
Marketing
This feature allows you to manage marketing functionalities such as creating and managing email campaigns. The code sample demonstrates how to create a new email campaign in HubSpot.
const hubspot = require('@hubspot/api-client');
const hubspotClient = new hubspot.Client({ apiKey: 'your-api-key' });
async function createEmailCampaign() {
const emailCampaignObj = { name: 'New Campaign', subject: 'Hello World', fromName: 'Your Company', fromEmail: 'info@yourcompany.com' };
const createResponse = await hubspotClient.marketing.emailCampaigns.create(emailCampaignObj);
console.log(createResponse);
}
createEmailCampaign();
Sales
This feature allows you to manage sales functionalities such as creating, reading, updating, and deleting deals. The code sample demonstrates how to create a new deal in HubSpot.
const hubspot = require('@hubspot/api-client');
const hubspotClient = new hubspot.Client({ apiKey: 'your-api-key' });
async function createDeal() {
const dealObj = { properties: { dealname: 'New Deal', amount: '1000', dealstage: 'qualifiedtobuy' } };
const createResponse = await hubspotClient.crm.deals.basicApi.create(dealObj);
console.log(createResponse);
}
createDeal();
Service
This feature allows you to manage service functionalities such as creating, reading, updating, and deleting tickets. The code sample demonstrates how to create a new support ticket in HubSpot.
const hubspot = require('@hubspot/api-client');
const hubspotClient = new hubspot.Client({ apiKey: 'your-api-key' });
async function createTicket() {
const ticketObj = { properties: { subject: 'Support Request', content: 'Need help with product', hs_pipeline: '0', hs_pipeline_stage: '1' } };
const createResponse = await hubspotClient.crm.tickets.basicApi.create(ticketObj);
console.log(createResponse);
}
createTicket();
Other packages similar to @hubspot/api-client
node-hubspot
The node-hubspot package is another client library for interacting with HubSpot's APIs. It offers similar functionalities to @hubspot/api-client but may have a different API design and feature set.
hubspot-api
The hubspot-api package provides a simplified interface for accessing HubSpot's APIs. It is designed to be easy to use and may be a good alternative for developers looking for a more lightweight solution.