{"id":13878039,"url":"https://github.com/HubSpot/hubspot-api-ruby","last_synced_at":"2025-07-16T14:30:46.812Z","repository":{"id":37787774,"uuid":"236371732","full_name":"HubSpot/hubspot-api-ruby","owner":"HubSpot","description":"HubSpot API Ruby Client Libraries for V3 version of the API","archived":false,"fork":false,"pushed_at":"2024-04-02T20:46:57.000Z","size":9505,"stargazers_count":108,"open_issues_count":18,"forks_count":50,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-26T15:37:03.328Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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}},"created_at":"2020-01-26T20:28:01.000Z","updated_at":"2024-06-18T18:41:41.587Z","dependencies_parsed_at":"2024-06-18T18:41:40.671Z","dependency_job_id":"838b816e-c621-440d-94a9-8f7b0d43d149","html_url":"https://github.com/HubSpot/hubspot-api-ruby","commit_stats":{"total_commits":475,"total_committers":8,"mean_commits":59.375,"dds":0.3789473684210526,"last_synced_commit":"dbe268d2e892fec401c9e7628349696170fee66f"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fhubspot-api-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fhubspot-api-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fhubspot-api-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fhubspot-api-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HubSpot","download_url":"https://codeload.github.com/HubSpot/hubspot-api-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226134226,"owners_count":17578778,"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":[],"created_at":"2024-08-06T08:01:38.156Z","updated_at":"2025-07-16T14:30:46.795Z","avatar_url":"https://github.com/HubSpot.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# hubspot-api-client\n\nRuby API v3 Client files and sample apps\n\n- API version: v3\n- Package version: 1.0.0\n- Build package: io.swagger.codegen.languages.RubyClientCodegen\n\n## Documentation\n\nSee the [Hubspot API](https://developers.hubspot.com/docs/api/overview) docs.\n\n## Installation\n\n```ruby\n\ngem install 'hubspot-api-client'\n\n```\n\n## Getting Started\n\nPlease follow the [installation](#installation) procedure and then run the following code:\n\n```ruby\n# Load the gem\nrequire 'hubspot-api-client'\n\n# Setup client\nclient = Hubspot::Client.new(access_token: 'your_access_token')\n\n# Get contacts\ncontacts = client.crm.contacts.basic_api.get_page\n```\n\n### Usage\n\n#### Hapikey support\n\nPlease, note that hapikey is no longer supported after v13.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### Get all\n\n`get_all` method is available for all objects (Companies, Contacts, Deals and etc).\n\n```ruby\nclient = Hubspot::Client.new(access_token: 'your_oauth2_access_token')\nall_contacts = client.crm.contacts.basic_api.get_all\n```\n\nYou'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 access token.\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\nOnly 3 `FilterGroups` with max 3 `Filters` are supported.\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```ruby\nclient.api_request({\n    \"method\": \"PUT\",\n    \"path\": \"/some/api/not/wrapped/yet\",\n    \"body\": {\"key\": \"value\"}\n})\n```\n\n## api_request options\n\n```ruby\n- \"method\": string, # Http method (e.g.: GET, POST, etc). Default value GET\n  \"path\": string, # URL path (e.g.: '/crm/v3/objects/contacts'). Optional\n  \"headers\": array, # Http headers. Optional.\n  \"body\": mixed, # Request body (if defaultJson set body will be transforted to json string).Optional.\n  \"auth_type\": (access_token, hapikey, developer_api_key), # Auth type. if it isn't set it will use access_token or hapikey. Default value is non empty auth_type.\n  \"auth_value\": string, # The corresponding value for the auth_type.\n  \"base_url\": string, # Base URL. Default value 'https://api.hubapi.com'.\n  \"qs\": array, # Query parameters. Optional.\n  \"default_json\": bool, # Default Json. if it is set to true it add to headers [ 'Content-Type' =\u003e 'application/json', 'Accept' =\u003e 'application/json, */*;q=0.8',]\n```\n\n### {Example} for `GET` request\n\n```ruby\nrequire 'hubspot-api-client'\n\nclient = Hubspot::Client.new(access_token: 'your_access_token')\n\noptions = {\n  method: \"GET\",\n  path: \"/crm/v3/objects/contacts\",\n  qs: {\n    limit: 1,\n    properties: [\"email\", \"last_activity_date\"]\n  }\n}\n\ncontacts = client.api_request(options)\n\np JSON.parse(contacts.body)\n```\n\n### {Example} for `POST` request\n\n```ruby\nrequire 'hubspot-api-client'\n\nclient = Hubspot::Client.new(access_token: 'your_access_token')\n\noptions = {\n  method: \"POST\",\n  path: \"/crm/v3/objects/contacts\",\n  body: {\n    \"properties\": {\n      \"email\": \"some_email@some.com\",\n      \"lastname\": \"some_last_name\"\n    }\n  }\n}\n\ncontacts = client.api_request(options)\n\np JSON.parse(contacts.body)\n```\n\n### Example search by date\n\n```ruby\nrequire 'hubspot-api-client'\nrequire 'date'\n\napi_client = Hubspot::Client.new(access_token: \"YOUR_ACCESS_TOKEN\")\n# timestamp in milliseconds\ntimestamp = (DateTime.parse(\"XXXX-XX-XXTXX:XX:XX.XXXZ\").to_time.to_f * 1000).to_i.to_s\nbody = {\n  \"filterGroups\":\n    [\n      {\n        \"filters\":[\n          {\n            \"value\": timestamp,\n            \"propertyName\":\"lastmodifieddate\",\n            \"operator\":\"EQ\"\n          }\n        ]\n      }\n    ]\n}\napi_response = api_client.crm.contacts.search_api.do_search(\n  body: body\n)\nputs api_response\n```\n\n### Crm Object Schemas client usage\n\n#### Creation\n\n```ruby\nclient = Hubspot::Client.new(access_token: 'your_oauth2_access_token')\n\nlabels = {\n  singular: 'My object',\n  plural: 'My objects'\n}\n\noption = {\n  label: 'Option A',\n  value: 'A',\n  description: 'Choice number one',\n  display_order: 1,\n  hidden: false\n}\n\nproperty = {\n  name: 'property001',\n  label: 'My object property',\n  group_name: 'my_object_information',\n  options: [option],\n  display_order: 2,\n  type: 'enumeration',\n  field_type: 'select'\n}\n\nbody = {\n  labels: labels,\n  required_properties: ['property001'],\n  searchable_properties: [],\n  primary_display_property: 'property001',\n  secondary_display_properties: [],\n  properties: [property],\n  associated_objects: ['CONTACT'],\n  name: 'my_object'\n}\n\napi_response = client.crm.schemas.core_api.create(body: body)\n```\n\n### Error handling\n\n#### You can rescue an ApiError by passing a block to the method\n\n```ruby\nrequire 'hubspot-api-client'\n\nclient = Hubspot::Client.new(access_token: 'your_access_token')\n\ncontacts = client.crm.contacts.basic_api.get_page { |error| error.message }\n```\n\n#### You can set number of retry attempts and delay in seconds before retry on specific status code of response.\n\nAvailable params:\n\n- max_retries (maximum number of retries)\n- seconds_delay (pause in seconds between retries)\n- passing a block (block that handles errors occured)\n\n```ruby\nrequire 'hubspot-api-client'\n\n# Set handlers of statuses you want to handle\nretry_config = {\n  500..530 =\u003e { max_retries: 2, seconds_delay: 2 },\n  400 =\u003e { max_retries: 3, seconds_delay: 3 }\n}\n\nclient = Hubspot::Client.new(access_token: 'your_access_token')\n\ncontacts = client.crm.contacts.basic_api.get_page(retry: retry_config) { |error| error.code }\n```\n\n### Sample apps\n\nPlease, take a look at our [Sample apps](https://github.com/HubSpot/sample-apps-list)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHubSpot%2Fhubspot-api-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHubSpot%2Fhubspot-api-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHubSpot%2Fhubspot-api-ruby/lists"}