I have been trying to fetch data from Hubspot with Python and I am completely lost now. Hopefully someone can help 🙏
I have got the API key, created a test dev account, created an app, got the cliend id, the client secret, pip installed Hubspot in Anaconda and done this (code found in the documentation):
from hubspot import HubSpot api_client = HubSpot(api_key='...')
I am still missing the code that I have no idea how to find despite reading the documentation. AND I also get this error message which doesn't even seem linked to the missing code:
AttributeError: 'Discovery' object has no attribute 'default_api'
I believe we are doing similar things. If you are using Python, I also assume you are using the hubspot-client-api library.
If so, I would use your test account and create a private app there. Use the api and ability to accept the private app token. Unless you are developing for the marketplace, I suggest to keep it simple and go the private app route in your test account and then move your code to a private app in the production account.
If you follow back Python Hubspot package source code, you'll see the class Discovery (packages/hubspot/discovery/crm/contacts/discovery.py) has no "default_api" method, but has a "basic_api" one. I think the method name has changed since the redaction of API documentation.
So, If you write api_client.auth.oauth.basic_api.create_token... it will works.
I did what you suggested @KMurray and I don't have an error message when doing so! 🙂 BUT When I try to call, for example:
api_client.crm.contacts.get_all()
I get an error message 😞
MaxRetryError: HTTPSConnectionPool(host='api.hubapi.com', port=443): Max retries exceeded with url: /crm/v3/objects/contacts?limit=100 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))
I believe we are doing similar things. If you are using Python, I also assume you are using the hubspot-client-api library.
If so, I would use your test account and create a private app there. Use the api and ability to accept the private app token. Unless you are developing for the marketplace, I suggest to keep it simple and go the private app route in your test account and then move your code to a private app in the production account.