PHPackages                             hubspot/api-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. hubspot/api-client

ActiveLibrary[API Development](/categories/api)

hubspot/api-client
==================

Hubspot API client

14.0.4(1mo ago)23914.2M—1.7%89[29 issues](https://github.com/HubSpot/hubspot-api-php/issues)[2 PRs](https://github.com/HubSpot/hubspot-api-php/pulls)15Apache-2.0PHPPHP &gt;=8.1CI passing

Since Apr 21Pushed 1w ago12 watchersCompare

[ Source](https://github.com/HubSpot/hubspot-api-php)[ Packagist](https://packagist.org/packages/hubspot/api-client)[ Docs](https://hubspot.com/)[ RSS](/packages/hubspot-api-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (80)Used By (15)

hubspot-api-php
===============

[](#hubspot-api-php)

[![Latest Packagist Version](https://camo.githubusercontent.com/dd7456a5a1dff185675238981dce7fa3d64ee7390a96a55df31ce875af7af481/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68756273706f742f6170692d636c69656e743f6c6f676f3d676974687562266c6f676f436f6c6f723d7768697465267374796c653d666c61742d737175617265)](https://packagist.org/packages/hubspot/api-client)[![Total Downloads](https://camo.githubusercontent.com/2ca78a7509e375bd87aa4b022ebff5804510929b5082f4c6e6ef7bb6d78f5355/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68756273706f742f6170692d636c69656e742e7376673f6c6f676f3d676974687562266c6f676f436f6c6f723d7768697465267374796c653d666c61742d737175617265)](https://packagist.org/packages/hubspot/api-client)

PHP [HubSpot API](https://developers.hubspot.com/docs/api/overview) v3 SDK(Client) files

Installation
------------

[](#installation)

```
composer require hubspot/api-client
```

Requirements
------------

[](#requirements)

The current package requirements are:

PHP &gt;= 8.1

### Sample apps

[](#sample-apps)

Please, take a look at our [Sample apps](https://github.com/HubSpot/sample-apps-list)

Quickstart
----------

[](#quickstart)

### To instantiate API Client using access token use Factory

[](#to-instantiate-api-client-using-access-token-use-factory)

```
$hubspot = \HubSpot\Factory::createWithAccessToken('your-access-token');
```

You'll need to create a [private app](https://developers.hubspot.com/docs/api/private-apps) to get your access token or you can obtain [OAuth2](https://developers.hubspot.com/docs/api/working-with-oauth) access token.

#### To instantiate API Client using developer apikey use Factory

[](#to-instantiate-api-client-using-developer-apikey-use-factory)

```
$hubspot = \HubSpot\Factory::createWithDeveloperApiKey('your-developer-apikey');
```

#### also you can pass custom client to Factory

[](#also-you-can-pass-custom-client-to-factory)

```
$client = new \GuzzleHttp\Client([...]);

$hubspot = \HubSpot\Factory::createWithAccessToken('your-access-token', $client);
```

#### To change the base path

[](#to-change-the-base-path)

```
$config = new \GuzzleHttp\Client();
$config->setBasePath('*');
$config->setAccessToken('*');
$config->setDeveloperApiKey('*');

$hubspot = \HubSpot\Factory::create(null, $config);
```

#### Retry Middleware

[](#retry-middleware)

The API client provides retry middleware for three failure scenarios: rate limiting (429), internal server errors (500–503, 520–599), and connection errors. All middleware retry up to `RetryMiddlewareFactory::DEFAULT_MAX_RETRIES` (5) times by default.

If no delay function is provided, Guzzle applies its built-in exponential backoff. Available delay helpers:

- `Delay::getConstantDelayFunction(int $secondsDelay = 10)` — fixed delay between retries
- `Delay::getLinearDelayFunction()` — delay grows linearly with retry count

Please note that Apps using OAuth are only subject to a limit of 100 requests every 10 seconds.

```
$handlerStack = \GuzzleHttp\HandlerStack::create();

// Retry on 429 with a constant 10-second delay
$handlerStack->push(
    \HubSpot\RetryMiddlewareFactory::createRateLimitMiddleware(
        \HubSpot\Delay::getConstantDelayFunction()
    )
);

// Retry on 5xx errors (exponential backoff by default)
$handlerStack->push(
    \HubSpot\RetryMiddlewareFactory::createInternalErrorsMiddleware()
);

// Retry on connection errors for cURL codes 52, 55, 56 (exponential backoff by default)
// Pass an empty array to retry all ConnectExceptions regardless of cURL error code
$handlerStack->push(
    \HubSpot\RetryMiddlewareFactory::createConnectionErrorsMiddleware()
);

$client = new \GuzzleHttp\Client(['handler' => $handlerStack]);

$hubspot = \HubSpot\Factory::createWithAccessToken('your-access-token', $client);
```

#### Get contacts page

[](#get-contacts-page)

```
$response = $hubspot->crm()->contacts()->basicApi()->getPage();
```

#### Get contact by email

[](#get-contact-by-email)

```
$contact = $hubSpot->crm()->contacts()->basicApi()->getById('example@example.com', null, null, null, false, 'email');
```

#### Search for a contact

[](#search-for-a-contact)

```
$filter = new \HubSpot\Client\Crm\Contacts\Model\Filter();
$filter
    ->setOperator('EQ')
    ->setPropertyName('email')
    ->setValue($search);

$filterGroup = new \HubSpot\Client\Crm\Contacts\Model\FilterGroup();
$filterGroup->setFilters([$filter]);

$searchRequest = new \HubSpot\Client\Crm\Contacts\Model\PublicObjectSearchRequest();
$searchRequest->setFilterGroups([$filterGroup]);

// Get specific properties
$searchRequest->setProperties(['firstname', 'lastname', 'date_of_birth', 'email']);

// @var CollectionResponseWithTotalSimplePublicObject $contactsPage
$contactsPage = $hubspot->crm()->contacts()->searchApi()->doSearch($searchRequest);
```

#### Create a contact

[](#create-a-contact)

```
$contactInput = new \HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInput();
$contactInput->setProperties([
    'email' => 'example@example.com'
]);

$contact = $hubspot->crm()->contacts()->basicApi()->create($contactInput);
```

#### Update a contact

[](#update-a-contact)

```
$newProperties = new \HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInput();
$newProperties->setProperties([
    'email' => 'updatedExample@example.com'
]);

$hubspot->crm()->contacts()->basicApi()->update($contactId, $newProperties);
```

#### Archive a contact

[](#archive-a-contact)

```
$hubspot->crm()->contacts()->basicApi()->archive($contactId);
```

#### Get custom objects page

[](#get-custom-objects-page)

```
$hubspot->crm()->objects()->basicApi()->getPage($objectType)
```

#### File uploading

[](#file-uploading)

```
$file = new \SplFileObject('file path');
$response = $hubspot->files()->filesApi()->upload($file, null, '/', null, null, json_encode([
    'access' => 'PRIVATE',
    'ttl' => 'P2W',
    'overwrite' => false,
    'duplicateValidationStrategy' => 'NONE',
    'duplicateValidationScope' => 'EXACT_FOLDER'
]) );
```

#### Not wrapped endpoint(s)

[](#not-wrapped-endpoints)

It is possible to access the hubspot request method directly, it could be handy if client doesn't have implementation for some endpoint yet. Exposed request method benefits by having all configured client params.

```
$response = $hubspot->apiRequest([
    'method' => 'PUT',
    'path' => '/some/api/not/wrapped/yet',
    'body' => ['key' => 'value'],
]);
```

#### apiRequest options

[](#apirequest-options)

```
[
    'method' => string, // Http method (e.g.: GET, POST, etc). Default value GET
    'path' => string, // URL path (e.g.: '/crm/v3/objects/contacts'). Optional
    'headers' => array, // Http headers. Optional.
    'body' => mixed, // Request body (if defaultJson set body will be transforted to json string).Optional.
    'authType' => enum(none, accessToken, hapikey, developerApiKey), // Auth type. if it isn't set it will use accessToken or hapikey. Default value is non empty auth type.
    'baseUrl' => string, // Base URL. Default value 'https://api.hubapi.com'.
    'qs' => array, // Query parameters. Optional.
    'defaultJson' => bool, // Default Json. if it is set to true it add to headers [ 'Content-Type' => 'application/json', 'Accept' => 'application/json, */*;q=0.8',]
    // and transfort body to json string. Default value true
];
```

#### get contacts

[](#get-contacts)

```
$response = $hubspot->apiRequest([
    'path' => '/crm/v3/objects/contacts',
]);
```

Reserved words
--------------

[](#reserved-words)

The SDK has reserved words(e.g. `clone`). [Full list of reserved words.](https://openapi-generator.tech/docs/generators/php#reserved-words)When you face with a reserved word you have to add `_` before the word(e.g. `_clone`).

Contributing
------------

[](#contributing)

### Run spec tests

[](#run-spec-tests)

```
vendor/bin/phpspec run
```

### Run unit tests

[](#run-unit-tests)

```
vendor/bin/phpunit ./tests
```

###  Health Score

73

—

ExcellentBetter than 100% of packages

Maintenance92

Actively maintained with recent releases

Popularity67

Solid adoption and visibility

Community40

Growing community involvement

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 88.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~28 days

Recently: every ~7 days

Total

77

Last Release

55d ago

Major Versions

9.4.0 → 10.0.0-beta2023-04-12

10.3.0 → 11.0.02024-03-06

11.3.0 → 12.0.02024-10-28

12.2.0 → 13.0.0beta.12025-04-28

13.2.0 → 14.0.02026-02-23

PHP version history (4 changes)1.0.0-betaPHP &gt;=7.2

5.0.0PHP &gt;=7.3

11.0.0PHP &gt;=7.4

14.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/dd27c781f688dfe9982c8444b17ec8740dce49f3a5f370f05bcfc84d61411023?d=identicon)[yfaktorovich](/maintainers/yfaktorovich)

![](https://www.gravatar.com/avatar/d1eb248181e2a92ac9f69dba8d3797429cb730daefece1f1bb8184cc483327a2?d=identicon)[ksvirkou-hubspot](/maintainers/ksvirkou-hubspot)

---

Top Contributors

[![ksvirkou-hubspot](https://avatars.githubusercontent.com/u/57258237?v=4)](https://github.com/ksvirkou-hubspot "ksvirkou-hubspot (1467 commits)")[![atanasiuk-hubspot](https://avatars.githubusercontent.com/u/57258334?v=4)](https://github.com/atanasiuk-hubspot "atanasiuk-hubspot (168 commits)")[![cholden-hubs](https://avatars.githubusercontent.com/u/228057148?v=4)](https://github.com/cholden-hubs "cholden-hubs (2 commits)")[![AScriver](https://avatars.githubusercontent.com/u/34779562?v=4)](https://github.com/AScriver "AScriver (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![PhilETaylor](https://avatars.githubusercontent.com/u/400092?v=4)](https://github.com/PhilETaylor "PhilETaylor (1 commits)")[![pimpeters](https://avatars.githubusercontent.com/u/9702432?v=4)](https://github.com/pimpeters "pimpeters (1 commits)")[![Rattone](https://avatars.githubusercontent.com/u/7362607?v=4)](https://github.com/Rattone "Rattone (1 commits)")[![rossjcooper](https://avatars.githubusercontent.com/u/3597958?v=4)](https://github.com/rossjcooper "rossjcooper (1 commits)")[![ryross](https://avatars.githubusercontent.com/u/152982?v=4)](https://github.com/ryross "ryross (1 commits)")[![taras-by](https://avatars.githubusercontent.com/u/15653428?v=4)](https://github.com/taras-by "taras-by (1 commits)")[![tiffany-taylor](https://avatars.githubusercontent.com/u/3333510?v=4)](https://github.com/tiffany-taylor "tiffany-taylor (1 commits)")[![yfaktor](https://avatars.githubusercontent.com/u/1022084?v=4)](https://github.com/yfaktor "yfaktor (1 commits)")[![ArthurGuy](https://avatars.githubusercontent.com/u/92837?v=4)](https://github.com/ArthurGuy "ArthurGuy (1 commits)")[![zzgael](https://avatars.githubusercontent.com/u/6159020?v=4)](https://github.com/zzgael "zzgael (1 commits)")[![asilverstein](https://avatars.githubusercontent.com/u/440978?v=4)](https://github.com/asilverstein "asilverstein (1 commits)")[![d3v1](https://avatars.githubusercontent.com/u/12612442?v=4)](https://github.com/d3v1 "d3v1 (1 commits)")[![julienNoksi](https://avatars.githubusercontent.com/u/57416053?v=4)](https://github.com/julienNoksi "julienNoksi (1 commits)")[![mattdfloyd](https://avatars.githubusercontent.com/u/185187?v=4)](https://github.com/mattdfloyd "mattdfloyd (1 commits)")

---

Tags

phpapisdkswaggerhubspot

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/hubspot-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/hubspot-api-client/health.svg)](https://phpackages.com/packages/hubspot-api-client)
```

###  Alternatives

[mailchimp/marketing

1647.3M23](/packages/mailchimp-marketing)[php-opencloud/openstack

PHP SDK for OpenStack APIs. Supports BlockStorage, Compute, Identity, Images, Networking and Metric Gnocchi

2292.2M24](/packages/php-opencloud-openstack)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[clever/clever-php

231.6k](/packages/clever-clever-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
