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

ActiveLibrary[API Development](/categories/api)

swithfr/api-client
==================

Hubspot API client

5.0.2(4y ago)042Apache-2.0PHPPHP &gt;=7.3

Since Apr 21Pushed 4y agoCompare

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

READMEChangelog (2)Dependencies (5)Versions (28)Used By (0)

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

[](#hubspot-api-php)

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

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

[](#installation)

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

### 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 HubSpot API Key use Factory:

[](#to-instantiate-api-client-using-hubspot-api-key-use-factory)

```
$hubSpot = \HubSpot\Factory::createWithApiKey('api-key');
```

#### or using OAuth2 access token:

[](#or-using-oauth2-access-token)

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

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

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

// @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($_POST);

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

#### Update a contact:

[](#update-a-contact)

```
$newProperties = new \HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInput();
$newProperties->setProperties($_POST);

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

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

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

[](#contributing)

### Run spec tests

[](#run-spec-tests)

```
vendor/bin/phpspec run

```

### Run unit tests

[](#run-unit-tests)

```
vendor/bin/phpunit ./tests

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 77.3% 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 ~24 days

Recently: every ~43 days

Total

27

Last Release

1585d ago

Major Versions

1.3.3 → 2.0.02020-08-25

2.8.1 → 3.0.12021-06-18

3.1.0 → 4.0.02021-09-07

v4.x-dev → 5.0.02021-12-15

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

5.0.0PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/50005ecd47c44870c4ad8fdfdf7bc858cf4c646023d25676ff277c7c37407008?d=identicon)[SwithFr](/maintainers/SwithFr)

---

Top Contributors

[![ksvirkou-hubspot](https://avatars.githubusercontent.com/u/57258237?v=4)](https://github.com/ksvirkou-hubspot "ksvirkou-hubspot (585 commits)")[![atanasiuk-hubspot](https://avatars.githubusercontent.com/u/57258334?v=4)](https://github.com/atanasiuk-hubspot "atanasiuk-hubspot (168 commits)")[![ArthurGuy](https://avatars.githubusercontent.com/u/92837?v=4)](https://github.com/ArthurGuy "ArthurGuy (1 commits)")[![asilverstein](https://avatars.githubusercontent.com/u/440978?v=4)](https://github.com/asilverstein "asilverstein (1 commits)")[![taras-by](https://avatars.githubusercontent.com/u/15653428?v=4)](https://github.com/taras-by "taras-by (1 commits)")[![yfaktor](https://avatars.githubusercontent.com/u/1022084?v=4)](https://github.com/yfaktor "yfaktor (1 commits)")

---

Tags

phpapisdkswaggerhubspot

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)[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)
