hubspot/api-client
The official HubSpot PHP client library for the v3 HubSpot API.
Repository Health
Technical Analysis
hubspot/api-client is HubSpot’s official PHP SDK for version 3 of the HubSpot API. It wraps the full breadth of HubSpot’s platform behind typed PHP clients, covering CRM objects (contacts, companies, deals), marketing, automation, CMS, conversations, events, files, and more, so PHP applications can integrate with HubSpot without hand-rolling HTTP requests.
Generated from HubSpot’s OpenAPI/Swagger definitions and built on Guzzle, the library provides a Factory for authenticating with an access token, developer API key, or OAuth2, plus configurable retry middleware and a discovery layer that organizes the many API surfaces into a navigable client tree.
What You Get
- Typed PHP clients covering CRM, marketing, automation, CMS, conversations, events, and files
- A
Factorysupporting access-token, developer-API-key, and OAuth2 authentication - Guzzle-based HTTP handling with configurable retry middleware
- A discovery layer that organizes HubSpot’s many API surfaces into a client tree
- Code generated from HubSpot’s OpenAPI definitions to track the live API
Common Use Cases
- Syncing contacts, companies, and deals between a PHP app and HubSpot CRM
- Automating marketing workflows and email events from server-side PHP
- Building integrations and private apps on top of the HubSpot platform
- Managing HubSpot CMS content or conversations programmatically
Under The Hood
Architecture - The library autoloads two PSR-4 roots: HubSpot\ from lib/ (hand-written glue like Factory.php, Config.php, Discovery, retry middleware, and enums) and HubSpot\Client\ from codegen/ (the generated per-endpoint API, model, and serializer classes). The Discovery tree groups product areas (Crm, Marketing, Automation, Cms, Conversations, Events, Files) so callers navigate from a single client object to the specific endpoint client they need.
Tech Stack - PHP 8.1+ built on guzzlehttp/guzzle 7 and guzzlehttp/psr7, requiring the curl, json, and mbstring extensions. The generated code originates from HubSpot’s Swagger/OpenAPI specs via the codegen/ toolchain, and development uses PHPUnit, phpspec, and php-cs-fixer.
Code Quality - As a generated SDK the bulk of the code is uniform and machine-produced, with a tests/ suite and phpspec specifications validating the hand-written layer. Consistent PSR-4 structure, dedicated config and retry-middleware classes, and CS-fixer enforcement keep the maintained surface tidy.
API Design - The developer experience is deliberately simple at the entry point: \HubSpot\Factory::createWithAccessToken('token') returns a client, and you drill into endpoints through the discovery tree. Because the endpoint methods are generated, naming follows the API’s own conventions and the extensive HubSpot developer documentation carries most of the onboarding, giving a moderate learning curve driven mainly by the size of the API rather than the SDK itself.