PHPackages                             s98-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. s98-hubspot/api-client

ActiveLibrary[API Development](/categories/api)

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

Hubspot API client

054PHP

Since Dec 12Pushed 2y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

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;= 7.3

### 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('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('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('access-token', $client);
```

#### To change the base path

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

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

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

#### API Client comes with Middleware for implementation of Rate and Concurrent Limiting

[](#api-client-comes-with-middleware-for-implementation-of-rate-and-concurrent-limiting)

It provides an ability to turn on retry for failed requests with statuses 429 or 500. Please note that Apps using OAuth are only subject to a limit of 100 requests every 10 seconds.

```
$handlerStack = \GuzzleHttp\HandlerStack::create();
$handlerStack->push(
    \HubSpot\RetryMiddlewareFactory::createRateLimitMiddleware(
        \HubSpot\Delay::getConstantDelayFunction()
    )
);

$handlerStack->push(
    \HubSpot\RetryMiddlewareFactory::createInternalErrorsMiddleware(
        \HubSpot\Delay::getExponentialDelayFunction(2)
    )
);

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

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

#### Get contacts page

[](#get-contacts-page)

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

#### 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(HubSpot\Crm\ObjectType::CONTACTS)
```

#### 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',
]);
```

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

[](#contributing)

### Run spec tests

[](#run-spec-tests)

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

### Run unit tests

[](#run-unit-tests)

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

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 Bus Factor1

Top contributor holds 82% 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.

### Community

Maintainers

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

---

Top Contributors

[![ksvirkou-hubspot](https://avatars.githubusercontent.com/u/57258237?v=4)](https://github.com/ksvirkou-hubspot "ksvirkou-hubspot (832 commits)")[![atanasiuk-hubspot](https://avatars.githubusercontent.com/u/57258334?v=4)](https://github.com/atanasiuk-hubspot "atanasiuk-hubspot (168 commits)")[![sarmadmakhdoom](https://avatars.githubusercontent.com/u/3525711?v=4)](https://github.com/sarmadmakhdoom "sarmadmakhdoom (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 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)")[![ArthurGuy](https://avatars.githubusercontent.com/u/92837?v=4)](https://github.com/ArthurGuy "ArthurGuy (1 commits)")[![yfaktor](https://avatars.githubusercontent.com/u/1022084?v=4)](https://github.com/yfaktor "yfaktor (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)")[![mattdfloyd](https://avatars.githubusercontent.com/u/185187?v=4)](https://github.com/mattdfloyd "mattdfloyd (1 commits)")

### Embed Badge

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

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M474](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M186](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M33](/packages/facebook-php-business-sdk)[microsoft/microsoft-graph

The Microsoft Graph SDK for PHP

65723.5M95](/packages/microsoft-microsoft-graph)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)

PHPackages © 2026

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