Is there a PHP library?



I have tried library which did not work out for me.

	require_once "haPiHP/class.contacts.php";
$HAPIKey = "cbxxxxea-xxxx-xxxx-xxxx-xxxa8axxxx98";
$contacts = new HubSpot_Contacts($HAPIKey);
$contacts_recent_batch1 = $contacts->get_recent_contacts('');

echo "<pre>";
echo "</pre>";

Above code returns an empty array.

Please guide.

EDIT: above code works when I have
$HAPIKey = 'demo';


@ar-hz I don’t believe that repository is up to date. It was last worked on in October of 2015. Did you choose php for that library or do you have experience coding in php


Thanks @pmanca We have a platform based on PHP and I need to integrate Hubspot with it. Therefore, I needed the PHP library. Is there a JS library tho?

If this library is outdated then I guess I just have to write the CURL method and make my own client-library?

Thanks again.


@ar-hz The best way might be able to make your own CURL methods, and client-library.

I have written a node.js library here which I can help you out with if you choose to go that route. I’d also be more then happy to work with you through PHP. I just can’t speak to that specific php library.


ok thanks. Node.js might be a no go for me. I am gonna create a php-client library. I will post here if I have any questions.

Thanks for your help :slight_smile:


FYI: still works. I had the API Key wrong earlier. So far I have only tested the forms endpoint.


@ar-hz Perfect I’m glad it is still working for you! Thanks for the heads up on it.


I think this is by far a much better PHP library to use the hubspot API. It is up-to-date and very intuitive. It also cover almost every API that hubspot provides.


I could not make this to work on my localhost (wamp on Windows).
Maybe because I did not have Guzzle.


I don’t mean to interfere with how you code your project. But you sound to me not using composer. If you are using composer, you should have no issue with the dependency of Guzzle.

Please follow this link to install composer:

And then you can install hubspot-php:

  1. open your Command Prompt,
  2. go to your project folder,
  3. type in ‘composer require “ryanwinchester/hubspot-php:~1.0”’
  4. wait…wait…and wait… (you then will see composer.json, composer.lock and vendor folder created)
  5. include the autoload.php inside vendor folder
  6. you are good to go

There are other settings and adjustments and stuff, but once you get used to using composer, your coding experience should be much better than now.

hope this help


Thanks a lot @phena109! I got nicely with this library all the contact data (except profile_token and profile_url that return value 0 for me) but can't find any example code to move on with updating contact data by vid or email when it's updated externally.

PS. I'm also trying to sync Hubspot (or something else you suggest - checking also Zoho and some others - haven't picked the one yet) and our external system in the way that we check the contact's last updated date and overwrite the older with newer if the date isn't equal. Only thing I know we can't get via API from HubSot is avatar but that's not an issue if we can send avatar to HubSpot via API (not sure about that yet).


thanks @phena109 i just install composer on my windows and then install the vendor.

But i can't run the library. I create index.php on the root directory, and type :
$hubspot = new SevenShores\Hubspot\Factory([
'key' => 'demo',
'oauth' => false, // default
'base_url' => '' // default

$contact = $hubspot->contacts()->getByEmail("");

echo $contact->properties->email->value;


i have error : Class 'SevenShores\Hubspot\Factory' not found

thanks for helping me