HubSpot API Client Edit
This is a full documentation of methods available to use in the HubSpot API client.
Getting started Edit
First of all you’re going to require HubSpot API key, which you can obtain by logging into your HubSpot account, clicking your profile icon an then going into Integrations -> HubSpot API key.
When you have the API key, you can install the client into your project using Composer. After it’s installed, you can create the instance in your code.
composer require danaketh/hubspot-client
There are two ways of using this API. Either using the wrapper class HubSpot
, which provides access to everything
through a single object and can be useful when you’re working with multiple endpoints at the same time. Or using
each API class on it’s own.
use danaketh\HubSpot\HubSpot;
use danaketh\HubSpot\API\ContactList;
$hubspot = new HubSpot('<API_KEY>');
$listOfContacts = $hubspot->contactList()->all();
$api = new ContactList('<API_KEY>');
$listOfContacts = $api->all();
To keep the documentation clean and easy to understand, we’re only using each class directly.
Response Edit
Response
code
HTTP code of the response
body
Actual response from the API endpoint as
array
content-type
Content-Type header returned by the endpoint
Every response returned by the client has the same structure with some useful information which may come in handy
if you ever need to do more than just get one or two things from time to time. Response is returned as an array
.
If for some reason the endpoint can’t be reached, client throws an exception RequestException
with the reason.
[
'code' => 200,
'body' => [],
'content-type' => 'text/html'
]
Blog Edit
Provides access to the Blog API endpoints
use danaketh\HubSpot\API\Blog;
$blog = new Blog('<API_KEY>');
::list Edit
List all of the blogs for a portal. Supports paging and filtering.
Parameters
Name | Type | Description |
---|---|---|
$filters |
array |
Array of filters applied to the result |
Filters
limit
The number of items to return. Defaults to 20
offset
The offset set to start returning rows from. Defaults to 0
created
exact
,range
,gt
,gte
,lt
,lte
- When the post was first created, in milliseconds since the epochdeleted_at
exact
,range
,gt
,gte
,lt
,lte
- When the post was deleted, in milliseconds since the epoch. Zero if the blog post was never deleted. Use a DELETE request to delete the post, do not set this directlyname
exact
,range
,gt
,gte
,lt
,lte
- The internal name of the blog
Response
allow_comments
Are comments enabled for the blog
Examples
$blogs = $blog->list([
'name' => [
'exact' => 'Example blog'
]
]);
You can find the API endpoint documentation at https://developers.hubspot.com/docs/methods/blogv2/get_blogs
[
[
''
]
]
{
"error": true,
"message": "Invalid offset"
}