# Issue using the basic API for fetching company list in python

**URL:** <https://community.hubspot.com/t/issue-using-the-basic-api-for-fetching-company-list-in-python/92332>\
**Category:** APIs & Integrations\
**Tags:** companies\
**Created:** [October 22, 2023, 3:30am UTC](https://community.hubspot.com/t/issue-using-the-basic-api-for-fetching-company-list-in-python/92332 "2023-10-22T03:30:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anrg](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@Anrg](https://community.hubspot.com/u/Anrg)\
**Post date:** [October 22, 2023, 3:30am UTC](https://community.hubspot.com/t/issue-using-the-basic-api-for-fetching-company-list-in-python/92332/1 "2023-10-22T03:30:54Z")

</div>

Issue ussing the basic API for fetching company list, The API doesn’t work using python 3.6

Code (taken from your website)

import hubspot  
from pprint import pprint  
from hubspot.crm.companies import ApiException  
max\_results = 500  
# hapikey = ‘pat-na1-455c4653-7117-415a-9805-013ee8af7e91’  
limit = 5  
company\_list = []  
get\_all\_companies\_url = “[https://api.hubapi.com/crm/v3/objects/companies](https://api.hubapi.com/crm/v3/objects/companies)”  
YOUR\_ACCESS\_TOKEN = “pat-”  
client = hubspot.Client.create(access\_token=“YOUR\_ACCESS\_TOKEN”)  
try:  
api\_response = client.crm.companies.basic\_api.get\_crm\_v3\_objects\_companies(limit=10, archived=False)  
pprint(api\_response)  
except ApiException as e:  
print(“Exception when calling basic\_api-\>get\_crm\_v3\_objects\_companies: %s\n” % e)

--------------

output

---------------

warnings.warn(  
Traceback (most recent call last):  
File “/Users/xxxx/pythonProject/pythonProject/pythonProject/pythonProject/scraper/python/hubspot\_conn.py”, line 16, in \<module\>  
api\_response = client.crm.companies.basic\_api.get\_crm\_v3\_objects\_companies(limit=10, archived=False)  
AttributeError: ‘BasicApi’ object has no attribute ‘get\_crm\_v3\_objects\_companies’

Process finished with exit code 1

---

<div class="post-metadata">

**Author:** ![Maciek-Magic](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Maciek-Magic](https://community.hubspot.com/u/Maciek-Magic)\
**Post date:** [October 23, 2023, 8:25am UTC](https://community.hubspot.com/t/issue-using-the-basic-api-for-fetching-company-list-in-python/92332/2 "2023-10-23T08:25:54Z")

</div>

Hi,

never post tokens!  
HIDE IT PLESE

`# hapikey = 'pat-na1-...'`

Not a python expert but I can see error there. In your custom code action use hapikey (privat app token) in this line like this:

`client = hubspot.Client.create(access_token="pat-na1-...")`

Best practice to test your code is to use test call in HubSpot API documentation page

and then use it in WF and then copy what you get there. Using Postman is another option. There you can choose supported libriaries listed [here](https://developers.hubspot.com/docs/api/workflows/custom-code-actions) I personally use axios as it is easy to read and troubleshoot for me.

 ![Screenshot 2023-10-23 102151.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/5/9/5926267a8ed79a46d4f186596866ca030c8c117d.png)
