APIs & Integrations

GTobin
Participant

What API resources are available on a free developer account?

SOLVE

I have a free developer hubspot account. I have tried to access api's like contacts with python code but it throws an error to say I do not have permission.

I read on the internet that some api's are not accessible on a free developer's account. My question is which api's and their resources are available?

0 Upvotes
1 Accepted solution
Jaycee_Lewis
Solution
Community Manager
Community Manager

What API resources are available on a free developer account?

SOLVE

Hey, @GTobin 👋 Can you provide any additional details? It may be easier to start with a specific example and work from there. 

Questions:

  • What specific endpoint are you using? For example, have you tried one from here? Contacts API
    GET /crm/v3/objects/contacts/{contactId}​
  • Can you add an example request and the response body here, along with the exact error? 
  • Does the error happen if you test directly from the example page, such as the one linked above?

Including details is the best way to give the community enough information to try to understand what is happening and if they can assist.

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

View solution in original post

5 Replies 5
GTobin
Participant

What API resources are available on a free developer account?

SOLVE

I tried using the api key method to list all contacts but I get an error saying that I do not have the correct permission.

 

import requests
import json
import urllib.parse
from hubspot import HubSpot
import hubspot
from pprint import pprint

max_results = 500
hapikey = '****************************'
count = 5
contact_list = []
get_all_contacts_url = "https://api.hubapi.com/contacts/v1/lists/all/contacts/all?"
parameter_dict = {'hapikey': hapikey, 'count': count}
headers = {}

parameters = urllib.parse.urlencode(parameter_dict)
get_url = get_all_contacts_url + parameters
r = requests.get(url= get_url, headers = headers)
print(r.text)

{"status":"error","message":"This hapikey (eu1-b8c6-f564-4bf4-b94f-570d5565a1e0) does not have proper permissions! (requires all of [contacts-read])","correlationId":"fd5f5e02-9e08-45b5-aef6-32bea451a777"}

 

I then tried the oauth method. I authenticate and get the code needed.

GTobin_1-1665741628253.png

I then use this code along with the client id, secret to get the access token

from hubspot.auth.oauth import ApiException
from hubspot import HubSpot
from hubspot.crm.contacts import SimplePublicObjectInput
from hubspot.crm.contacts.exceptions import ApiException
from hubspot.auth.oauth import ApiException


api_client = HubSpot(access_token='***********************')

try:
tokens = api_client.auth.oauth.default_api.create_token(
grant_type="authorization_code",
redirect_uri='http://localhost',
client_id='******************************',
client_secret='***************************',
code='********************'
)
except ApiException as e:
print("Exception when calling create_token method: %s\n" % e)
print(tokens)

 

{'access_token': 'CPGh4a29MBIHAAEAQAAAARituMUMIIvVvxYo6JFGMhQefnCJMmHc9BLziwmnA5VRQpe8ZjowAAAAQQAAAAAAAAAAAAAAAACAAAAAAAAAAAAAIAAAAAAA4AEAAAAAAAAAAAAAABACQhQd_P1KFLJc4_6QpjH1dbCPSVuSJUoDZXUxUgBaAA',
 'expires_in': 1800,
 'refresh_token': 'eu1-64fa-942a-49cf-bbdd-fc9cfb991c3e'}

 I then use the access token and all contacts are returned

import hubspot
from pprint import pprint
from hubspot.crm.contacts import ApiException

client = hubspot.Client.create(access_token="CPGh4a29MBIHAAEAQAAAARituMUMIIvVvxYo6JFGMhQefnCJMmHc9BLziwmnA5VRQpe8ZjowAAAAQQAAAAAAAAAAAAAAAACAAAAAAAAAAAAAIAAAAAAA4AEAAAAAAAAAAAAAABACQhQd_P1KFLJc4_6QpjH1dbCPSVuSJUoDZXUxUgBaAA")

try:
api_response = client.crm.contacts.basic_api.get_page(limit=10, archived=False)
pprint(api_response)
except ApiException as e:
print("Exception when calling basic_api->get_page: %s\n" % e)

 

{'paging': None,
 'results': [{'archived': False,
              'archived_at': None,
              'associations': None,
              'created_at': datetime.datetime(2022, 9, 29, 14, 56, 43, 828000, tzinfo=tzutc()),
              'id': '1',
              'properties': {'createdate': '2022-09-29T14:56:43.828Z',
                             'email': 'emailmaria@hubspot.com',
                             'firstname': 'Maria',
                             'hs_object_id': '1',
                             'lastmodifieddate': '2022-09-29T14:56:54.927Z',
                             'lastname': 'Johnson (Sample Contact)'},
              'updated_at': datetime.datetime(2022, 9, 29, 14, 56, 54, 927000, tzinfo=tzutc())},
             {'archived': False,
              'archived_at': None,
              'associations': None,
              'created_at': datetime.datetime(2022, 9, 29, 14, 56, 44, 108000, tzinfo=tzutc()),
              'id': '51',
              'properties': {'createdate': '2022-09-29T14:56:44.108Z',
                             'email': 'bh@hubspot.com',
                             'firstname': 'Brian',
                             'hs_object_id': '51',
                             'lastmodifieddate': '2022-09-29T14:56:49.192Z',
                             'lastname': 'Halligan (Sample Contact)'},
              'updated_at': datetime.datetime(2022, 9, 29, 14, 56, 49, 192000, tzinfo=tzutc())},
             {'archived': False,
              'archived_at': None,
              'associations': None,
              'created_at': datetime.datetime(2022, 10, 13, 15, 17, 4, 773000, tzinfo=tzutc()),
              'id': '101',
              'properties': {'createdate': '2022-10-13T15:17:04.773Z',
                             'email': 'email@example.com',
                             'firstname': None,
                             'hs_object_id': '101',
                             'lastmodifieddate': '2022-10-13T15:17:33.863Z',
                             'lastname': None},
              'updated_at': datetime.datetime(2022, 10, 13, 15, 17, 33, 863000, tzinfo=tzutc())}]}

 

I cannot get this work using the api key method but can using the oauth method.

0 Upvotes
GTobin
Participant

What API resources are available on a free developer account?

SOLVE

I tried using the api key method to list all contacts but I get an error saying that I do not have the correct permission.

 

 

 

import requests
import json
import urllib.parse
from hubspot import HubSpot
import hubspot
from pprint import pprint

max_results = 500
hapikey = '***********************'
count = 5
contact_list = []
get_all_contacts_url = "https://api.hubapi.com/contacts/v1/lists/all/contacts/all?"
parameter_dict = {'hapikey': hapikey, 'count': count}
headers = {}

parameters = urllib.parse.urlencode(parameter_dict)
get_url = get_all_contacts_url + parameters
r = requests.get(url= get_url, headers = headers)
print(r.text)

 

{"status":"error","message":"This hapikey (eu1-b8c6-f564-4bf4-b94f-570d5565a1e0) does not have proper permissions! (requires all of [contacts-read])","correlationId":"fd5f5e02-9e08-45b5-aef6-32bea451a777"}

 

I then tried the oauth method. I authenticate and get the code needed.

 

GTobin_1-1665737029398.png

I then use this code along with the client id, secret to get the access token

from hubspot.auth.oauth import ApiException
from hubspot import HubSpot
from hubspot.crm.contacts import SimplePublicObjectInput
from hubspot.crm.contacts.exceptions import ApiException
from hubspot.auth.oauth import ApiException


api_client = HubSpot(access_token='*************')

try:
tokens = api_client.auth.oauth.default_api.create_token(
grant_type="authorization_code",
redirect_uri='http://localhost',
client_id='******',
client_secret='******************',
code='eu1-2fbb-6882-4aac-92a7-71ffb8038c9f'
)
except ApiException as e:
print("Exception when calling create_token method: %s\n" % e)
print(tokens)

 

{'access_token': 'CPGh4a29MBIHAAEAQAAAARituMUMIIvVvxYo6JFGMhQefnCJMmHc9BLziwmnA5VRQpe8ZjowAAAAQQAAAAAAAAAAAAAAAACAAAAAAAAAAAAAIAAAAAAA4AEAAAAAAAAAAAAAABACQhQd_P1KFLJc4_6QpjH1dbCPSVuSJUoDZXUxUgBaAA',
 'expires_in': 1800,
 'refresh_token': 'eu1-64fa-942a-49cf-bbdd-fc9cfb991c3e'}

 

I then use the access token and all contacts are returned

 

import hubspot
from pprint import pprint
from hubspot.crm.contacts import ApiException

client = hubspot.Client.create(access_token="CPGh4a29MBIHAAEAQAAAARituMUMIIvVvxYo6JFGMhQefnCJMmHc9BLziwmnA5VRQpe8ZjowAAAAQQAAAAAAAAAAAAAAAACAAAAAAAAAAAAAIAAAAAAA4AEAAAAAAAAAAAAAABACQhQd_P1KFLJc4_6QpjH1dbCPSVuSJUoDZXUxUgBaAA")

try:
api_response = client.crm.contacts.basic_api.get_page(limit=10, archived=False)
pprint(api_response)
except ApiException as e:
print("Exception when calling basic_api->get_page: %s\n" % e)

 

{'paging': None,
 'results': [{'archived': False,
              'archived_at': None,
              'associations': None,
              'created_at': datetime.datetime(2022, 9, 29, 14, 56, 43, 828000, tzinfo=tzutc()),
              'id': '1',
              'properties': {'createdate': '2022-09-29T14:56:43.828Z',
                             'email': 'emailmaria@hubspot.com',
                             'firstname': 'Maria',
                             'hs_object_id': '1',
                             'lastmodifieddate': '2022-09-29T14:56:54.927Z',
                             'lastname': 'Johnson (Sample Contact)'},
              'updated_at': datetime.datetime(2022, 9, 29, 14, 56, 54, 927000, tzinfo=tzutc())},
             {'archived': False,
              'archived_at': None,
              'associations': None,
              'created_at': datetime.datetime(2022, 9, 29, 14, 56, 44, 108000, tzinfo=tzutc()),
              'id': '51',
              'properties': {'createdate': '2022-09-29T14:56:44.108Z',
                             'email': 'bh@hubspot.com',
                             'firstname': 'Brian',
                             'hs_object_id': '51',
                             'lastmodifieddate': '2022-09-29T14:56:49.192Z',
                             'lastname': 'Halligan (Sample Contact)'},
              'updated_at': datetime.datetime(2022, 9, 29, 14, 56, 49, 192000, tzinfo=tzutc())},
             {'archived': False,
              'archived_at': None,
              'associations': None,
              'created_at': datetime.datetime(2022, 10, 13, 15, 17, 4, 773000, tzinfo=tzutc()),
              'id': '101',
              'properties': {'createdate': '2022-10-13T15:17:04.773Z',
                             'email': 'email@example.com',
                             'firstname': None,
                             'hs_object_id': '101',
                             'lastmodifieddate': '2022-10-13T15:17:33.863Z',
                             'lastname': None},
              'updated_at': datetime.datetime(2022, 10, 13, 15, 17, 33, 863000, tzinfo=tzutc())}]}
In [ ]:
 
I cannot get this work using the api key method but can using the oauth method.
 
 
 

 

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

What API resources are available on a free developer account?

SOLVE

Here's a list of API's by HubSpot Hub and tier https://developers.hubspot.com/apisbytier

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
Jaycee_Lewis
Solution
Community Manager
Community Manager

What API resources are available on a free developer account?

SOLVE

Hey, @GTobin 👋 Can you provide any additional details? It may be easier to start with a specific example and work from there. 

Questions:

  • What specific endpoint are you using? For example, have you tried one from here? Contacts API
    GET /crm/v3/objects/contacts/{contactId}​
  • Can you add an example request and the response body here, along with the exact error? 
  • Does the error happen if you test directly from the example page, such as the one linked above?

Including details is the best way to give the community enough information to try to understand what is happening and if they can assist.

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

GTobin
Participant

What API resources are available on a free developer account?

SOLVE
Hi Jaycee,
I am using thevfollowing code
 
parameter_dict = {'hapikey': hapikey, 'count': count}
headers = {}

# Paginate your request using offset
has_more = True
while has_more:
    parameters = urllib.parse.urlencode(parameter_dict)
    get_url = get_all_contacts_url + parameters
    r = requests.get(url= get_url, headers = headers)
 
I get the following response
{"status":"error","message":"This hapikey (eu1-b8c6-f564-4bf4-b94f-570d5565a1e0) does not have proper permissions! (requires all of [contacts-read])","correlationId":"b554730e-17dd-49c7-acc4-53ca36338f9e"}
0 Upvotes