The API is allow you to create a functional application or integration quickly and easily. JSON will be returned in all responses from the API, including errors. The API needs two types of authentication, one is OAuth and the other is API keys.
We can test API using HubSpot demo portal by signing in using the below credentials.
Login: https://login.hubspot.com/login/?loginPortalId=62515 Username : firstname.lastname@example.org Password : HubSpot API Key : demo OAuth Token : demooooo-oooo-oooo-oooo-oooooooooooo Hub ID : 62515
We can refer contact API as an example. Contact API store lead-specific data which makes it possible to leverage most of the functionalities in HubSpot, from marketing automation, and to lead scoring to smarter contents.
Create a new contact in HubSpot with a simple HTTP POST to the Contacts API. The contact created inside HubSpot, and it had unique ID so we can easily retrieve contact inside of HubSpot later. The API URL is,
'https://api.hubapi.com/contacts/v1/contact?hapikey=' . $hubspot_apikey';
For example :
<?php $val = array( array( 'property' => 'email_Id', 'value' => 'email@example.com' ), array( 'property' => 'mob_no', 'value' => '5587878' ) ) ); $json_value= json_encode($val); $hubspot_apikey = 'demo'; $api_url = 'https://api.hubapi.com/contacts/v1/contact?hapikey=' . $hubspot_apikey; $c = @curl_init(); @curl_setopt($c, CURLOPT_POST, true); @curl_setopt($c, CURLOPT_POSTFIELDS, $json_value); @curl_setopt($c, CURLOPT_URL, $endpoint); @curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); @curl_setopt($c, CURLOPT_RETURNTRANSFER, true); $response = @curl_exec($c); @curl_close($c); echo $response; ?>