{"id":31970522,"url":"https://github.com/hubspot/hubspot-api-python","last_synced_at":"2025-10-14T19:16:05.332Z","repository":{"id":37758284,"uuid":"248865684","full_name":"HubSpot/hubspot-api-python","owner":"HubSpot","description":"HubSpot API Python Client Libraries for V3 version of the API","archived":false,"fork":false,"pushed_at":"2025-09-09T11:44:17.000Z","size":4937,"stargazers_count":388,"open_issues_count":11,"forks_count":119,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-09-28T05:29:06.420Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HubSpot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-03-20T22:41:24.000Z","updated_at":"2025-09-17T11:10:01.000Z","dependencies_parsed_at":"2023-02-02T12:31:58.886Z","dependency_job_id":"980a9deb-eb1b-4a64-b39f-245e4c83411a","html_url":"https://github.com/HubSpot/hubspot-api-python","commit_stats":{"total_commits":438,"total_committers":20,"mean_commits":21.9,"dds":0.3287671232876712,"last_synced_commit":"9411808dc634c64c6a488973af586f40d30ad0e4"},"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"purl":"pkg:github/HubSpot/hubspot-api-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fhubspot-api-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fhubspot-api-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fhubspot-api-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fhubspot-api-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HubSpot","download_url":"https://codeload.github.com/HubSpot/hubspot-api-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fhubspot-api-python/sbom","scorecard":{"id":63566,"data":{"date":"2025-08-11","repo":{"name":"github.com/HubSpot/hubspot-api-python","commit":"d1eff4b5846f8a4c7cdbc96a2c72930b8d96bb80"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.2,"checks":[{"name":"Code-Review","score":10,"reason":"all changesets reviewed","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/pythonapp.yml:1","Warn: no topLevel permission defined: .github/workflows/pythonintegrationtest.yml:1","Warn: no topLevel permission defined: .github/workflows/pythonpublish.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pythonapp.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/HubSpot/hubspot-api-python/pythonapp.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pythonapp.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/HubSpot/hubspot-api-python/pythonapp.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pythonintegrationtest.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/HubSpot/hubspot-api-python/pythonintegrationtest.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pythonintegrationtest.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/HubSpot/hubspot-api-python/pythonintegrationtest.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pythonpublish.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/HubSpot/hubspot-api-python/pythonpublish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pythonpublish.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/HubSpot/hubspot-api-python/pythonpublish.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pythonpublish.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/HubSpot/hubspot-api-python/pythonpublish.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/pythonpublish.yml:23","Warn: pipCommand not pinned by hash: .github/workflows/pythonpublish.yml:24","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   2 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/pythonpublish.yml:11"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-15T02:11:09.502Z","repository_id":37758284,"created_at":"2025-08-15T02:11:09.502Z","updated_at":"2025-08-15T02:11:09.502Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020649,"owners_count":26086895,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-10-14T19:15:58.189Z","updated_at":"2025-10-14T19:16:05.319Z","avatar_url":"https://github.com/HubSpot.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hubspot-api-python\n\nPython [HubSpot API](https://developers.hubspot.com/docs/api/overview) v3 SDK(Client) files and sample apps\n\nSample Applications can be found in [Sample apps](https://github.com/HubSpot/sample-apps-list)\n\n## Documentation\n\nSee the [API docs](https://developers.hubspot.com/docs/api/overview).\n\n## Installation\n\nIf you just want to use the package, run:\n\n```bash\npip install --upgrade hubspot-api-client\n```\n\n### Requirements\n\nMake sure you have [Python 3.7+](https://docs.python.org/3/) and [pip](https://pypi.org/project/pip/) installed.\n\n## Quickstart\n\n### Configuring HubSpot client\n\n```python\nfrom hubspot import HubSpot\n\napi_client = HubSpot(access_token='your_access_token')\n\n# or set your access token later\napi_client = HubSpot()\napi_client.access_token = 'your_access_token'\n```\n\nYou'll need to create a [private app](https://developers.hubspot.com/docs/apps/legacy-apps/private-apps) to get your access token or you can obtain OAuth2 access token.\n\n#### Hapikey support\n\nPlease, note that hapikey is no longer supported after v5.1.0. You can get more info about hapikey sunset [here](https://developers.hubspot.com/changelog/upcoming-api-key-sunset). Also, plese, visit a [migration guide](https://developers.hubspot.com/docs/api/migrate-an-api-key-integration-to-a-private-app) if you need help with a migration process.\n\n### OAuth API\n\n#### Obtain OAuth2 access token\n\n```python\nfrom hubspot.oauth import ApiException\n\ntry:\n    tokens = api_client.oauth.tokens_api.create(\n        grant_type=\"authorization_code\",\n        redirect_uri='http://localhost',\n        client_id='client_id',\n        client_secret='client_secret',\n        code='code'\n    )\nexcept ApiException as e:\n    print(\"Exception when calling create_token method: %s\\n\" % e)\n```\n\n### CRM API\n\n#### Create contact\n\n```python\nfrom hubspot.crm.contacts import SimplePublicObjectInputForCreate\nfrom hubspot.crm.contacts.exceptions import ApiException\n\ntry:\n    simple_public_object_input_for_create = SimplePublicObjectInputForCreate(\n        properties={\"email\": \"email@example.com\"}\n    )\n    api_response = api_client.crm.contacts.basic_api.create(\n        simple_public_object_input_for_create=simple_public_object_input_for_create\n    )\nexcept ApiException as e:\n    print(\"Exception when creating contact: %s\\n\" % e)\n```\n\n#### Get contact by id\n\n```python\nfrom hubspot.crm.contacts import ApiException\n\ntry:\n    contact_fetched = api_client.crm.contacts.basic_api.get_by_id('contact_id')\nexcept ApiException as e:\n    print(\"Exception when requesting contact by id: %s\\n\" % e)\n```\n\n#### Get custom objects page\n\n```python\nfrom hubspot.crm.objects import ApiException\n\ntry:\n    my_custom_objects_page = api_client.crm.objects.basic_api.get_page(object_type=\"my_custom_object_type\")\nexcept ApiException as e:\n    print(\"Exception when requesting custom objects: %s\\n\" % e)\n```\n\n#### Get all\n\n`get_all` method is available for all objects (Companies, Contacts, Deals and etc).\n\n```python\nall_contacts = api_client.crm.contacts.get_all()\n```\n\nPlease note that pagination is used under the hood to get all results.\n\n## Search\n\n`do_search` method is available for all objects (Companies, Contacts, Deals and etc).\n\n### Example Search by date\n\n```python\nimport hubspot\n\nfrom dateutil import parser\nfrom pprint import pprint\nfrom hubspot.crm.contacts import PublicObjectSearchRequest, ApiException\n\napi_client = hubspot.Client.create(access_token=\"YOUR_ACCESS_TOKEN\")\n\n# timestamp in milliseconds\ndate = str(int(parser.isoparse(\"XXXX-XX-XXTXX:XX:XX.XXXZ\").timestamp() * 1000))\npublic_object_search_request = PublicObjectSearchRequest(\n    filter_groups=[\n        {\n            \"filters\": [\n                {\n                    \"value\": date,\n                    \"propertyName\": \"lastmodifieddate\",\n                    \"operator\": \"EQ\"\n                }\n            ]\n        }\n    ], limit=10\n)\ntry:\n    api_response = api_client.crm.contacts.search_api.do_search(public_object_search_request=public_object_search_request)\n    pprint(api_response)\nexcept ApiException as e:\n    print(\"Exception when calling search_api-\u003edo_search: %s\\n\" % e)\n\n```\n\n### CMS API\n\n#### Get audit logs\n\n```python\nfrom hubspot.cms.audit_logs import ApiException\n\ntry:\n    audit_logs_page = api_client.cms.audit_logs.default_api.get_page()\nexcept ApiException as e:\n    print(\"Exception when calling cards_api-\u003ecreate: %s\\n\" % e)\n```\n\n### Files API\n\n#### Upload files\n\n```python\nimport hubspot\nimport json\nfrom pprint import pprint\nfrom hubspot.crm.contacts import ApiException\n\nclient = hubspot.Client.create(access_token=\"your_access_token\")\n\noptions = json.dumps(\n    {'access': 'PRIVATE',\n     \"overwrite\": False}\n)\n\ntry:\n    response = client.files.files_api.upload(\n        file=\"/file/path/file.jpeg\",\n        file_name=\"name_in_hubspot\",\n        folder_path=\"folder_in_hubspot\",\n        options=options,\n    )\n    pprint(response)\n\nexcept ApiException as e:\n    print(\"Exception when calling basic_api-\u003eget_page: %s\\n\" % e)\n```\n\n## Not wrapped endpoint(s)\n\nIt is possible to access the hubspot request method directly,\nit could be handy if client doesn't have implementation for some endpoint yet.\nExposed request method benefits by having all configured client params.\n\n```python\nclient.api_request({\n    \"method\": \"PUT\",\n    \"path\": \"/some/api/not/wrapped/yet\",\n    \"body\": {\"key\": \"value\"}\n})\n```\n\n### {Example} for `GET` request\n\n```python\nimport hubspot\nfrom pprint import pprint\nfrom hubspot.crm.contacts import ApiException\n\nclient = hubspot.Client.create(access_token=\"your_access_token\")\n\ntry:\n    response = client.api_request(\n        {\"path\": \"/crm/v3/objects/contacts\"}\n    )\n    pprint(response)\nexcept ApiException as e:\n    print(e)\n```\n\n### {Example} for `POST` request\n\n```python\nimport hubspot\nfrom pprint import pprint\nfrom hubspot.crm.contacts import ApiException\n\nclient = hubspot.Client.create(access_token=\"your_access_token\")\n\ntry:\n    response = client.api_request(\n        {\n            \"path\": \"/crm/v3/objects/contacts\",\n            \"method\": \"POST\",\n            \"body\": {\n                \"properties\":\n                    {\n                        \"email\": \"some_email@some.com\",\n                        \"lastname\": \"some_last_name\"\n                    },\n            }\n        }\n\n    )\n    pprint(response.json())\nexcept ApiException as e:\n    print(e)\n```\n\n### Using utils\n\n#### Get OAuth url\n\n```python\nfrom hubspot.utils.oauth import get_auth_url\n\nauth_url = get_auth_url(\n    scope=('contacts',),\n    client_id='client_id',\n    redirect_uri='http://localhost'\n)\n```\n\n#### Validate HubSpot request signature\n\n[Example](./sample-apps/webhooks-app/src/routes/webhooks.py) of usage from [Webhooks Sample App](./sample-apps/webhooks-app):\n\n```python\nimport os\nfrom flask import request\nfrom hubspot.utils.signature import Signature\n\nSignature.is_valid(\n    signature=request.headers[\"X-HubSpot-Signature\"],\n    client_secret=os.getenv(\"HUBSPOT_CLIENT_SECRET\"),\n    request_body=request.data.decode(\"utf-8\"),\n    http_uri=request.base_url,\n    signature_version=request.headers[\"X-HubSpot-Signature-Version\"],\n    timestamp=request.headers[\"X-HubSpot-Request-Timestamp\"]\n)\n```\n\n### Retry middleware\n\nYou can pass an instance of [urllib3.util.retry.Retry](https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html) class to configure http client retries.\nWith internal error retry middleware:\n\n```python\nfrom hubspot import HubSpot\nfrom urllib3.util.retry import Retry\n\nretry = Retry(\n    total=3,\n    backoff_factor=0.3,\n    status_forcelist=(500, 502, 504),\n)\napi_client = HubSpot(retry=retry)\n```\n\nOr with rate limit retry middleware:\n\n```python\nfrom hubspot import HubSpot\nfrom urllib3.util.retry import Retry\n\nretry = Retry(\n    total=5,\n    status_forcelist=(429,),\n)\napi_client = HubSpot(retry=retry)\n```\n\n### Convert response object to dict\n\n`to_dict` method is available for most response objects\n\n```python\ncontacts = api_client.crm.contacts.basic_api.get_page()\nfor contact in contacts.results:\n    print(contact.to_dict())\n```\n\n## Sample Apps\n\nPlease, take a look at our [Sample apps](https://github.com/HubSpot/sample-apps-list)\n\n## Contributing\n\nInstall the package locally:\n\n```\npip install -e .\n```\n\nSet up the development virtualenv:\n\n```\nmake\n```\n\nRun tests:\n```\nmake test\n```\n\nRun [Black](https://github.com/psf/black) for code formatting:\n```\nmake fmt\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhubspot%2Fhubspot-api-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhubspot%2Fhubspot-api-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhubspot%2Fhubspot-api-python/lists"}