GET data with API from Ads (Marketing)

Hello. How can i get data from Ads in Marketing Section?

*Note from the moderator:
This content appears to be created with the help of AI tools and might be of low relevance or could contain incorrect information.
We recommend fact-checking the content.
Please use AI responsibly going forward (see Community Guidelines).
Hello @HGozcu ,

I jhope this helps you.

To get data from Ads in the Marketing Section using HubSpot API, you can follow these steps:

  1. First, you will need to obtain an API key from HubSpot. You can do this by going to your HubSpot account settings, clicking on “Integrations” in the left-hand menu, and then selecting “API key.”
  2. Once you have your API key, you can use it to authenticate your API requests. You can do this by adding the API key to the “Authorization” header of your API requests.
  3. To retrieve data from Ads in the Marketing section, you can use the Ads API endpoints provided by HubSpot. These endpoints allow you to retrieve data such as ad campaigns, ad sets, and ads.
  4. You can use the following endpoint to retrieve ad campaigns:

bash


​GET /ads/v1/campaigns
This endpoint returns a list of ad campaigns with their associated metadata

  1. You can use the following endpoint to retrieve ad sets:

bash

GET /ads/v1/ads-sets

This endpoint returns a list of ad sets with their associated metadata.

  1. Finally, you can use the following endpoint to retrieve ads:

bash

GET /ads/v1/ads

This endpoint returns a list of ads with their associated metadata.

By using these API endpoints, you can retrieve data from Ads in the Marketing section of HubSpot.

Thnak you

Shubham Nigam

Hey SNigam. Thank you for reply. When i send request to https://api.hubapi.com/ads/v1/campaigns i get

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Resource not found</p>
</body>
</html>

My code;

import requests
token = my_token

# set the API endpoint
url = “https://api.hubapi.com/ads/v1/campaigns”

# set the headers with the Authorization token
headers = {
“Authorization”: f"Bearer {token}",
“Content-Type”: “application/json”
}

# send the API request
response = requests.get(url, headers=headers)

print(response.text)
# print the response
print(response.json())

What should i do? Thanks

Hey @SNigam

Where did you get this information from?

It does not seem to work for me as well