# GET data with API from Ads (Marketing)

**URL:** <https://community.hubspot.com/t/get-data-with-api-from-ads-marketing/78530>\
**Category:** APIs & Integrations\
**Tags:** ads\
**Created:** [March 31, 2023, 8:48pm UTC](https://community.hubspot.com/t/get-data-with-api-from-ads-marketing/78530 "2023-03-31T20:48:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HGozcu](https://avatars.discourse-cdn.com/v4/letter/h/6f9a4e/32.png) [@HGozcu](https://community.hubspot.com/u/HGozcu)\
**Post date:** [March 31, 2023, 8:48pm UTC](https://community.hubspot.com/t/get-data-with-api-from-ads-marketing/78530/1 "2023-03-31T20:48:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![SNigam](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/snigam/32/24290_2.png) [@SNigam](https://community.hubspot.com/u/SNigam)\
**Post date:** [April 2, 2023, 7:59am UTC](https://community.hubspot.com/t/get-data-with-api-from-ads-marketing/78530/2 "2023-04-02T07:59:31Z")

</div>

_\*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](https://community.hubspot.com/t5/Getting-Started-on-the-Community/HubSpot-Community-Guidelines/ba-p/384050#:~:text=revoked%20Community%20membership.-,2.%20Be%20relevant.,-There%E2%80%99s%20a%20lot))._  
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

```auto

```

`​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

---

<div class="post-metadata">

**Author:** ![HGozcu](https://avatars.discourse-cdn.com/v4/letter/h/6f9a4e/32.png) [@HGozcu](https://community.hubspot.com/u/HGozcu)\
**Post date:** [April 3, 2023, 11:04am UTC](https://community.hubspot.com/t/get-data-with-api-from-ads-marketing/78530/3 "2023-04-03T11:04:51Z")

</div>

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

```auto
<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](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

---

<div class="post-metadata">

**Author:** ![DaniSt](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@DaniSt](https://community.hubspot.com/u/DaniSt)\
**Post date:** [July 27, 2023, 1:18pm UTC](https://community.hubspot.com/t/get-data-with-api-from-ads-marketing/78530/4 "2023-07-27T13:18:37Z")

</div>

Hey @SNigam

Where did you get this information from?

It does not seem to work for me as well
