{"id":13767514,"url":"https://github.com/HubSpot/hubspot-php","last_synced_at":"2025-05-10T23:30:45.234Z","repository":{"id":23058877,"uuid":"26412217","full_name":"HubSpot/hubspot-php","owner":"HubSpot","description":"HubSpot PHP API Client","archived":false,"fork":false,"pushed_at":"2025-04-28T06:10:45.000Z","size":1621,"stargazers_count":359,"open_issues_count":0,"forks_count":197,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-05-07T18:06:27.931Z","etag":null,"topics":["api","api-client","api-rest","api-wrapper","hubspot","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HubSpot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-11-09T22:53:56.000Z","updated_at":"2025-04-25T12:22:41.000Z","dependencies_parsed_at":"2024-06-18T11:08:56.118Z","dependency_job_id":"f6cab818-e237-4755-9657-e15cd40c8891","html_url":"https://github.com/HubSpot/hubspot-php","commit_stats":{"total_commits":630,"total_committers":100,"mean_commits":6.3,"dds":0.680952380952381,"last_synced_commit":"3918e2fdcd7bdb93ac539b4046a5cebf30a5ecdc"},"previous_names":[],"tags_count":60,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fhubspot-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fhubspot-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fhubspot-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fhubspot-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HubSpot","download_url":"https://codeload.github.com/HubSpot/hubspot-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253497296,"owners_count":21917683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-client","api-rest","api-wrapper","hubspot","php"],"created_at":"2024-08-03T16:01:09.292Z","updated_at":"2025-05-10T23:30:44.109Z","avatar_url":"https://github.com/HubSpot.png","language":"PHP","funding_links":[],"categories":["Integrations"],"sub_categories":["PHP"],"readme":"# HubSpot PHP API client\n\n[![Version](https://img.shields.io/packagist/v/hubspot/hubspot-php.svg?style=flat-square)](https://packagist.org/packages/hubspot/hubspot-php)\n[![Total Downloads](https://img.shields.io/packagist/dt/hubspot/hubspot-php.svg?style=flat-square)](https://packagist.org/packages/hubspot/hubspot-php)\n[![Build Status](https://travis-ci.org/hubspot/hubspot-php.svg?branch=master)](https://travis-ci.org/hubspot/hubspot-php)\n[![License](https://img.shields.io/packagist/l/hubspot/hubspot-php.svg?style=flat-square)](https://packagist.org/packages/hubspot/hubspot-php)\n\n[Hubspot](https://www.hubspot.com/) is a marketing, sales, and service software that helps your business grow without compromise. Because “good for the business” should also mean “good for the customer.”\n\n## This library supports only [legacy API](https://legacydocs.hubspot.com/docs/overview)\n\nPlease consider switching to [the latest API](https://github.com/HubSpot/hubspot-api-php).\n\n## Setup\n\n**Composer:**\n\n```bash\ncomposer require \"hubspot/hubspot-php\"\n```\n\n## Sample apps\n\n[Link](https://github.com/HubSpot/integration-examples-php)\n\n## Quickstart\n\n### Examples Using Factory\n\nAll following examples assume this step.\n\n```php\n$hubspot = SevenShores\\Hubspot\\Factory::create('api-key');\n\n// OR create with access token (OAuth2 or Private App)\n\n$hubspot = SevenShores\\Hubspot\\Factory::createWithAccessToken('access-token');\n\n// OR instantiate by passing a configuration array.\n// The only required value is the 'key'\n// Please note: as of November 30, 2022, HubSpot API Keys are being deprecated and are no longer supported.\n\n$hubspot = new SevenShores\\Hubspot\\Factory([\n    'key'      =\u003e 'demo',\n    'oauth2'   =\u003e false, // default\n]);\n\n// Then you can call a resource\n// When referencing endpoints, use camelCase\n\n$hubspot-\u003econtactlists\n```\n\nYou can find more information about oauth2 access tokens [here](https://developers.hubspot.com/docs/api/oauth/tokens) and about private app access token [here](https://developers.hubspot.com/docs/api/private-apps).\n\n*Note:* You can prevent any error handling provided by this package by passing following options into client creation routine:\n(applies also to `Factory::create()` and `Factory::createWithAccessToken()`)\n\n```php\n$hubspot = new SevenShores\\Hubspot\\Factory(\n    [\n        'key' =\u003e 'demo',\n    ],\n    null,\n    [\n        'http_errors' =\u003e false // pass any Guzzle related option to any request, e.g. throw no exceptions\n    ],\n    false // return Guzzle Response object for any -\u003erequest(*) call\n);\n```\n\nBy setting `http_errors` to false, you will not receive any exceptions at all, but pure responses.\nFor possible options, see http://docs.guzzlephp.org/en/latest/request-options.html.\n\n#### API Client comes with Middleware for implementation of Rate and Concurrent Limiting\n\nIt provides an ability to turn on retry for failed requests with statuses 429 or 500. You can read more about working within the HubSpot API rate limits [here](https://developers.hubspot.com/docs/faq/working-within-the-hubspot-api-rate-limits).\n\n```php\n$handlerStack = \\GuzzleHttp\\HandlerStack::create();\n$handlerStack-\u003epush(\n    \\SevenShores\\Hubspot\\RetryMiddlewareFactory::createRateLimitMiddleware(\n        \\SevenShores\\Hubspot\\Delay::getConstantDelayFunction()\n    )\n);\n\n$handlerStack-\u003epush(\n    \\SevenShores\\Hubspot\\RetryMiddlewareFactory::createInternalErrorsMiddleware(\n        \\SevenShores\\Hubspot\\Delay::getExponentialDelayFunction(2)\n    )\n);\n\n$guzzleClient = new \\GuzzleHttp\\Client(['handler' =\u003e $handlerStack]);\n\n$config = [\n    'key' =\u003e 'access token',\n    'oauth2' =\u003e true,\n];\n\n$hubspot = new \\SevenShores\\Hubspot\\Factory($config, new \\SevenShores\\Hubspot\\Http\\Client($config, $guzzleClient));\n```\n\n#### Get a single contact\n\n```php\n$contact = $hubspot-\u003econtacts()-\u003egetByEmail(\"test@hubspot.com\");\n\necho $contact-\u003eproperties-\u003eemail-\u003evalue;\n```\n\n#### Paginate through all contacts\n\n```php\n// Get an array of 10 contacts\n// getting only the firstname and lastname properties\n// and set the offset to 123456\n$response = $hubspot-\u003econtacts()-\u003eall([\n    'count'     =\u003e 10,\n    'property'  =\u003e ['firstname', 'lastname'],\n    'vidOffset' =\u003e 123456,\n]);\n```\n\nWorking with the data is easy!\n\n```php\nforeach ($response-\u003econtacts as $contact) {\n    echo sprintf(\n        \"Contact name is %s %s.\" . PHP_EOL,\n        $contact-\u003eproperties-\u003efirstname-\u003evalue,\n        $contact-\u003eproperties-\u003elastname-\u003evalue\n    );\n}\n\n// Info for pagination\necho $response-\u003e{'has-more'};\necho $response-\u003e{'vid-offset'};\n```\n\nor if you prefer to use array access?\n\n```php\nforeach ($response['contacts'] as $contact) {\n    echo sprintf(\n        \"Contact name is %s %s.\" . PHP_EOL,\n        $contact['properties']['firstname']['value'],\n        $contact['properties']['lastname']['value']\n    );\n}\n\n// Info for pagination\necho $response['has-more'];\necho $response['vid-offset'];\n```\n\nNow with response methods implementing [PSR-7 ResponseInterface](https://github.com/php-fig/http-message/tree/master/src)\n\n```php\n$response-\u003egetStatusCode()   // 200;\n$response-\u003egetReasonPhrase() // 'OK';\n// etc...\n```\n\n### Example Without Factory\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\n\nuse SevenShores\\Hubspot\\Http\\Client;\nuse SevenShores\\Hubspot\\Endpoints\\Contacts;\n\n$client = new Client(['key' =\u003e 'access token', 'oauth2' =\u003e true,]);\n\n$contacts = new Contacts($client);\n\n$response = $contacts-\u003eall();\n\nforeach ($response-\u003econtacts as $contact) {\n    //\n}\n```\n\n### Example of using built in utils\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\n\nuse SevenShores\\Hubspot\\Utils\\OAuth2;\n\n$authUrl = OAuth2::getAuthUrl(\n    'clientId',\n    'http://localhost/callaback.php',\n    'contacts'\n);\n\n```\n\nor using Factory:\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\n\nuse SevenShores\\Hubspot\\Utils;\n\n$authUrl = Utils::getFactory()-\u003eoAuth2()-\u003egetAuthUrl(\n    'clientId',\n    'http://localhost/callaback.php',\n    'contacts'\n);\n\n```\n\n## Status\n\nIf you see something not planned, that you want, make an [issue](https://github.com/HubSpot/hubspot-php/issues) and there's a good chance I will add it.\n\n- [x] Analytics API\n- [x] Calendar API :updated:\n- [x] Companies API :updated:\n- [x] Company Properties API :updated:\n- [x] Contacts API :updated:\n- [x] Contact Lists API :updated:\n- [x] Contact Properties API :updated:\n- [ ] Conversations Live Chat Widget API (Front End)\n- [x] CMS Blog API (Blogs) :updated:\n- [x] CMS Blog Authors API (BlogAuthors) :updated:\n- [x] CMS Blog Comments API (BlogComments)\n- [x] CMS Blog Post API (BlogPosts)\n- [x] CMS Blog Topics API (BlogTopics)\n- [ ] CMS Domains API\n- [x] CMS Files API (Files)\n- [x] CMS HubDB API (HubDB) :updated:\n- [ ] CMS Layouts API\n- [x] CMS Page Publishing API (Pages)\n- [ ] CMS Site Maps\n- [ ] CMS Site Search API\n- [ ] CMS Templates API\n- [ ] CMS URL Mappings API\n- [x] CRM Associations API\n- [ ] CRM Extensions API\n- [x] CRM Object Properties API (ObjectProperties) :new:\n- [x] CRM Pipelines API (CrmPipelines)\n- [x] Deals API\n- [x] Deal Pipelines API :deprecated:\n- [x] Deal Properties API :updated:\n- [x] Ecommerce Bridge API :updated:\n- [x] Email Subscription API :updated:\n- [x] Email Events API :updated:\n- [x] Engagements API\n- [x] Events API\n- [x] Forms API :updated:\n- [x] Line Items API :new:\n- [ ] Marketing Email API\n- [x] Owners API :updated:\n- [x] Products API :new:\n- [x] Social Media API\n- [x] Tickets API\n- [x] Timeline API :updated:\n- [ ] Tracking Code API\n- [x] Transactional Email API\n- [x] Workflows API :updated:\n- [x] Webhooks API\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHubSpot%2Fhubspot-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHubSpot%2Fhubspot-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHubSpot%2Fhubspot-php/lists"}