The update version of a code to access deals via API does not work for me.
import hubspot
from pprint import pprint
from hubspot.crm.deals import
client = hubspot.Client.create(api_key=“YOUR_HUBSPOT_API_KEY”);
try:
api_response = client.crm.deals.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)
However, the old version worked just fine.
What is the problem?
Thank you!
First, want to make sure you saw @BJacobson 's resource that he shared. It is contacts specific, but is good info.
Secondly, going to also throw @JBeatty into the mix here for some help 
Hi @VDrigin,
I am not super familiar with the python API for HubSpot, but after copying your code and modifying it slightly I got this to work:
from hubspot import HubSpot
from pprint import pprint
client = HubSpot(api_key="YOUR_API_KEY")
try:
api_response = client.crm.deals.basic_api.get_page(limit=10, archived=False)
pprint(api_response)
except Exception as e:
print("Exception when calling basic_api->get_page: %s\n" % e)
I believe the issue with your original code was how you were creating your client, and with how you were importing the HubSpot library.
Hi,
Now I am getting the following error:
SyntaxError: You must include a hapi_key or access_token attribute when initalizing the API
Thank you!
Hi @VDrigin,
What line of the code is giving the error? Also what version of python are you running? Also, try to update the package using:
pip install --upgrade hubspot-api-client
Thank you!
Updating the library worked!
system
7
Hi @VDrigin ,
Please try with below code and get deals.
<?php
$url = ‘https://api.hubapi.com/deals/v1/deal/paged?hapikey=demo&includeAssociations=true&limit=2&properties=dealname’;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ‘GET’);
$headers = array();
$headers[] = ‘Content-Type: application/json’;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo ‘Error:’ . curl_error($ch);
}
curl_close($ch);
$result = json_decode($result);
return $result;
?>
Documentation Link : Accounts Dashboard | HubSpot
Hope this helps!
If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.