curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890", {
method: "GET",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {'Authorization': 'Bearer API_KEY'}
r = requests.get('https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890', headers=headers)
print(r.json())
<?php
$apiUrl = 'https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890';
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey,
];
$curl = curl_init($apiUrl);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers
]);
$response = curl_exec($curl);
if ($response === false) {
echo 'Curl error: ' . curl_error($curl);
} else {
echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
}
curl_close($curl);
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace HistoryGETRequest_csharp
{
class History
{
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
try
{
var response = await client.GetStringAsync(url);
Console.WriteLine(response);
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}
}
{
"status": "success",
"ads": [
{
"postId": "DE6gpw8kxlonHy6eb721",
"ad": {
"accountId": "274948331",
"adId": "6683876017501",
"budgetRemaining": 0,
"created": "2025-03-30T10:11:34-0700",
"creativeId": "1033490148629541",
"dailyBudget": 0,
"deliveryStatus": "ACTIVE",
"endDate": "2025-04-03T22:30:00.000Z",
"fbPostId": "106638148652329_672633202087922",
"goal": {
"title": "Get More Engagement",
"description": "This goal seeks to increase engagement while ensuring that the ad reaches the maximum number of unique users. It balances visibility with engagement, showing the ad to as many different people as possible who may interact with it.",
"type": "engagement"
},
"isComplete": false,
"lifetimeBudget": 0,
"metrics": {
"spend": 9.21,
"impressions": 6495,
"reach": 6272,
"clicks": 3,
"ctr": 0.046189,
"cpm": 1.418014,
"cpp": 1.468431,
"frequency": 1.035555,
"uniqueClicks": 3,
"uniqueCtr": 0.047832,
"costPerUniqueClick": 3.07,
"inlineLinkClicks": 0,
"costPerInlineLinkClick": 0,
"outboundClicks": 0,
"costPerOutboundClick": 0,
"websiteCtr": [],
"accountCurrency": "USD",
"accountName": "John Doe",
"accountId": "274948331"
},
"name": "API Post - DE6gpw8kxlonHy6eb7L1 - 2025-03-30T17:11:26",
"previewLink": "https://fb.me/22Cn31wXlzhxOC1",
"spend": 9.21,
"startDate": "2025-03-30T17:11:32.000Z",
"status": "ACTIVE",
"targeting": {
"ageMax": 65,
"ageMin": 18,
"geoLocations": {
"countries": [
"US"
],
"locationTypes": [
"home",
"recent"
]
},
"interests": [
{
"id": "6003195554098",
"name": "Rhythm and blues music"
}
]
}
}
}
],
"count": 1
}
{
"status": "success",
"ads": [
{
"postId": "DE6gpw8kxlonHy6eb7Lo",
"ad": {
"accountId": "274948331",
"adId": "6683876017501",
"budgetRemaining": 0,
"created": "2025-03-30T10:11:34-0700",
"creativeId": "1033490148629541",
"dailyBudget": 0,
"deliveryStatus": "ACTIVE",
"endDate": "2025-04-03T22:30:00.000Z",
"fbPostId": "106638148652329_672633202087921",
"goal": {
"title": "Get More Engagement",
"description": "This goal seeks to increase engagement while ensuring that the ad reaches the maximum number of unique users. It balances visibility with engagement, showing the ad to as many different people as possible who may interact with it.",
"type": "engagement"
},
"isComplete": false,
"lifetimeBudget": 0,
"metrics": {
"spend": 9.21,
"impressions": 6495,
"reach": 6272,
"clicks": 3,
"ctr": 0.046189,
"cpm": 1.418014,
"cpp": 1.468431,
"frequency": 1.035555,
"uniqueClicks": 3,
"uniqueCtr": 0.047832,
"costPerUniqueClick": 3.07,
"inlineLinkClicks": 0,
"costPerInlineLinkClick": 0,
"outboundClicks": 0,
"costPerOutboundClick": 0,
"websiteCtr": [],
"accountCurrency": "USD",
"accountName": "John Doe",
"accountId": "274948331"
},
"name": "API Post - DE6gpw8kxlonHy6eb7Lo - 2025-03-30T17:11:26",
"previewLink": "https://fb.me/22Cn31wXlzhxOC1",
"spend": 9.21,
"startDate": "2025-03-30T17:11:32.000Z",
"status": "ACTIVE",
"targeting": {
"ageMax": 65,
"ageMin": 18,
"geoLocations": {
"countries": ["US"],
"locationTypes": ["home", "recent"]
},
"interests": [
{
"id": "6003195554098",
"name": "Rhythm and blues music"
}
]
}
}
},
{
"ad": {
"accountId": "274948331",
"adId": "6685225314301",
"budgetRemaining": 0,
"created": "2025-03-30T18:36:39-0700",
"creativeId": "628434386637341",
"dailyBudget": 0,
"deliveryStatus": "PAUSED",
"endDate": "2025-04-03T22:30:00.000Z",
"fbPostId": "106638148652329_672633202087921",
"goal": {
"title": "Get More Engagement",
"description": "This goal seeks to increase engagement while ensuring that the ad reaches the maximum number of unique users. It balances visibility with engagement, showing the ad to as many different people as possible who may interact with it.",
"type": "engagement"
},
"isComplete": false,
"lifetimeBudget": 0,
"metrics": {},
"name": "API Post 14 - 106638148652329_672633202087926 - 2025-03-31T01:36:32",
"previewLink": "https://fb.me/2nPlTIZEpzrCnY1",
"spend": 0,
"startDate": "2025-03-31T01:36:37.000Z",
"status": "PAUSED",
"targeting": {
"ageMax": 65,
"ageMin": 18,
"geoLocations": {
"countries": ["US"],
"locationTypes": ["home", "recent"]
},
"interests": [
{
"id": "6003195554098",
"name": "Rhythm and blues music"
}
]
}
}
}
],
"count": 2
}
{
"action": "get ads",
"status": "error",
"code": 370,
"message": "Error getting ads. Please try again or contact us if the issue persists."
}
Facebook Ads
Anúncios impulsionados
Obter anúncios impulsionados da sua conta do Facebook
GET
/
ads
/
facebook
/
ads
curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890", {
method: "GET",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {'Authorization': 'Bearer API_KEY'}
r = requests.get('https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890', headers=headers)
print(r.json())
<?php
$apiUrl = 'https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890';
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey,
];
$curl = curl_init($apiUrl);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers
]);
$response = curl_exec($curl);
if ($response === false) {
echo 'Curl error: ' . curl_error($curl);
} else {
echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
}
curl_close($curl);
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace HistoryGETRequest_csharp
{
class History
{
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
try
{
var response = await client.GetStringAsync(url);
Console.WriteLine(response);
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}
}
{
"status": "success",
"ads": [
{
"postId": "DE6gpw8kxlonHy6eb721",
"ad": {
"accountId": "274948331",
"adId": "6683876017501",
"budgetRemaining": 0,
"created": "2025-03-30T10:11:34-0700",
"creativeId": "1033490148629541",
"dailyBudget": 0,
"deliveryStatus": "ACTIVE",
"endDate": "2025-04-03T22:30:00.000Z",
"fbPostId": "106638148652329_672633202087922",
"goal": {
"title": "Get More Engagement",
"description": "This goal seeks to increase engagement while ensuring that the ad reaches the maximum number of unique users. It balances visibility with engagement, showing the ad to as many different people as possible who may interact with it.",
"type": "engagement"
},
"isComplete": false,
"lifetimeBudget": 0,
"metrics": {
"spend": 9.21,
"impressions": 6495,
"reach": 6272,
"clicks": 3,
"ctr": 0.046189,
"cpm": 1.418014,
"cpp": 1.468431,
"frequency": 1.035555,
"uniqueClicks": 3,
"uniqueCtr": 0.047832,
"costPerUniqueClick": 3.07,
"inlineLinkClicks": 0,
"costPerInlineLinkClick": 0,
"outboundClicks": 0,
"costPerOutboundClick": 0,
"websiteCtr": [],
"accountCurrency": "USD",
"accountName": "John Doe",
"accountId": "274948331"
},
"name": "API Post - DE6gpw8kxlonHy6eb7L1 - 2025-03-30T17:11:26",
"previewLink": "https://fb.me/22Cn31wXlzhxOC1",
"spend": 9.21,
"startDate": "2025-03-30T17:11:32.000Z",
"status": "ACTIVE",
"targeting": {
"ageMax": 65,
"ageMin": 18,
"geoLocations": {
"countries": [
"US"
],
"locationTypes": [
"home",
"recent"
]
},
"interests": [
{
"id": "6003195554098",
"name": "Rhythm and blues music"
}
]
}
}
}
],
"count": 1
}
{
"status": "success",
"ads": [
{
"postId": "DE6gpw8kxlonHy6eb7Lo",
"ad": {
"accountId": "274948331",
"adId": "6683876017501",
"budgetRemaining": 0,
"created": "2025-03-30T10:11:34-0700",
"creativeId": "1033490148629541",
"dailyBudget": 0,
"deliveryStatus": "ACTIVE",
"endDate": "2025-04-03T22:30:00.000Z",
"fbPostId": "106638148652329_672633202087921",
"goal": {
"title": "Get More Engagement",
"description": "This goal seeks to increase engagement while ensuring that the ad reaches the maximum number of unique users. It balances visibility with engagement, showing the ad to as many different people as possible who may interact with it.",
"type": "engagement"
},
"isComplete": false,
"lifetimeBudget": 0,
"metrics": {
"spend": 9.21,
"impressions": 6495,
"reach": 6272,
"clicks": 3,
"ctr": 0.046189,
"cpm": 1.418014,
"cpp": 1.468431,
"frequency": 1.035555,
"uniqueClicks": 3,
"uniqueCtr": 0.047832,
"costPerUniqueClick": 3.07,
"inlineLinkClicks": 0,
"costPerInlineLinkClick": 0,
"outboundClicks": 0,
"costPerOutboundClick": 0,
"websiteCtr": [],
"accountCurrency": "USD",
"accountName": "John Doe",
"accountId": "274948331"
},
"name": "API Post - DE6gpw8kxlonHy6eb7Lo - 2025-03-30T17:11:26",
"previewLink": "https://fb.me/22Cn31wXlzhxOC1",
"spend": 9.21,
"startDate": "2025-03-30T17:11:32.000Z",
"status": "ACTIVE",
"targeting": {
"ageMax": 65,
"ageMin": 18,
"geoLocations": {
"countries": ["US"],
"locationTypes": ["home", "recent"]
},
"interests": [
{
"id": "6003195554098",
"name": "Rhythm and blues music"
}
]
}
}
},
{
"ad": {
"accountId": "274948331",
"adId": "6685225314301",
"budgetRemaining": 0,
"created": "2025-03-30T18:36:39-0700",
"creativeId": "628434386637341",
"dailyBudget": 0,
"deliveryStatus": "PAUSED",
"endDate": "2025-04-03T22:30:00.000Z",
"fbPostId": "106638148652329_672633202087921",
"goal": {
"title": "Get More Engagement",
"description": "This goal seeks to increase engagement while ensuring that the ad reaches the maximum number of unique users. It balances visibility with engagement, showing the ad to as many different people as possible who may interact with it.",
"type": "engagement"
},
"isComplete": false,
"lifetimeBudget": 0,
"metrics": {},
"name": "API Post 14 - 106638148652329_672633202087926 - 2025-03-31T01:36:32",
"previewLink": "https://fb.me/2nPlTIZEpzrCnY1",
"spend": 0,
"startDate": "2025-03-31T01:36:37.000Z",
"status": "PAUSED",
"targeting": {
"ageMax": 65,
"ageMin": 18,
"geoLocations": {
"countries": ["US"],
"locationTypes": ["home", "recent"]
},
"interests": [
{
"id": "6003195554098",
"name": "Rhythm and blues music"
}
]
}
}
}
],
"count": 2
}
{
"action": "get ads",
"status": "error",
"code": 370,
"message": "Error getting ads. Please try again or contact us if the issue persists."
}
Recupere anúncios que foram impulsionados para uma publicação específica do Facebook.
Este endpoint de anúncios impulsionados fornece informações detalhadas sobre os anúncios impulsionados, incluindo status, gasto atual, métricas de desempenho (analytics) e links de visualização.
- As métricas são totais em tempo real dos anúncios. Se precisar de dados históricos, use o endpoint de histórico de anúncios.
- A URL
previewLinkpermite compartilhar o anúncio de visualização com seus colegas, para que possam ver o anúncio por 24 horas nos vários formatos do Facebook. As visualizações do anúncio pelos seus colegas não serão contabilizadas no gasto do seu anúncio.
Parâmetros de cabeçalho
Parâmetros de consulta
Recupera todos os anúncios sob o ID da conta.Obrigatório se
adId, fbPostId ou postId não estiverem definidos.Recupera um anúncio pelo ID do anúncio.Obrigatório se
accountId, fbPostId ou postId não estiverem definidos.Recupera anúncios pelo ID da publicação social do Facebook.Obrigatório se
accountId, adId ou postId não estiverem definidos.Recupera no máximo
limit anúncios. O máximo é 500.Recupera anúncios pelo ID da publicação da Ayrshare.Obrigatório se
accountId, adId ou fbPostId não estiverem definidos.Filtra anúncios por status do anúncio. Valores válidos são:
activepauseddeletedarchived
curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890", {
method: "GET",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {'Authorization': 'Bearer API_KEY'}
r = requests.get('https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890', headers=headers)
print(r.json())
<?php
$apiUrl = 'https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890';
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey,
];
$curl = curl_init($apiUrl);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers
]);
$response = curl_exec($curl);
if ($response === false) {
echo 'Curl error: ' . curl_error($curl);
} else {
echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
}
curl_close($curl);
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace HistoryGETRequest_csharp
{
class History
{
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/ads/facebook/ads?adId=1234567890";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
try
{
var response = await client.GetStringAsync(url);
Console.WriteLine(response);
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}
}
{
"status": "success",
"ads": [
{
"postId": "DE6gpw8kxlonHy6eb721",
"ad": {
"accountId": "274948331",
"adId": "6683876017501",
"budgetRemaining": 0,
"created": "2025-03-30T10:11:34-0700",
"creativeId": "1033490148629541",
"dailyBudget": 0,
"deliveryStatus": "ACTIVE",
"endDate": "2025-04-03T22:30:00.000Z",
"fbPostId": "106638148652329_672633202087922",
"goal": {
"title": "Get More Engagement",
"description": "This goal seeks to increase engagement while ensuring that the ad reaches the maximum number of unique users. It balances visibility with engagement, showing the ad to as many different people as possible who may interact with it.",
"type": "engagement"
},
"isComplete": false,
"lifetimeBudget": 0,
"metrics": {
"spend": 9.21,
"impressions": 6495,
"reach": 6272,
"clicks": 3,
"ctr": 0.046189,
"cpm": 1.418014,
"cpp": 1.468431,
"frequency": 1.035555,
"uniqueClicks": 3,
"uniqueCtr": 0.047832,
"costPerUniqueClick": 3.07,
"inlineLinkClicks": 0,
"costPerInlineLinkClick": 0,
"outboundClicks": 0,
"costPerOutboundClick": 0,
"websiteCtr": [],
"accountCurrency": "USD",
"accountName": "John Doe",
"accountId": "274948331"
},
"name": "API Post - DE6gpw8kxlonHy6eb7L1 - 2025-03-30T17:11:26",
"previewLink": "https://fb.me/22Cn31wXlzhxOC1",
"spend": 9.21,
"startDate": "2025-03-30T17:11:32.000Z",
"status": "ACTIVE",
"targeting": {
"ageMax": 65,
"ageMin": 18,
"geoLocations": {
"countries": [
"US"
],
"locationTypes": [
"home",
"recent"
]
},
"interests": [
{
"id": "6003195554098",
"name": "Rhythm and blues music"
}
]
}
}
}
],
"count": 1
}
{
"status": "success",
"ads": [
{
"postId": "DE6gpw8kxlonHy6eb7Lo",
"ad": {
"accountId": "274948331",
"adId": "6683876017501",
"budgetRemaining": 0,
"created": "2025-03-30T10:11:34-0700",
"creativeId": "1033490148629541",
"dailyBudget": 0,
"deliveryStatus": "ACTIVE",
"endDate": "2025-04-03T22:30:00.000Z",
"fbPostId": "106638148652329_672633202087921",
"goal": {
"title": "Get More Engagement",
"description": "This goal seeks to increase engagement while ensuring that the ad reaches the maximum number of unique users. It balances visibility with engagement, showing the ad to as many different people as possible who may interact with it.",
"type": "engagement"
},
"isComplete": false,
"lifetimeBudget": 0,
"metrics": {
"spend": 9.21,
"impressions": 6495,
"reach": 6272,
"clicks": 3,
"ctr": 0.046189,
"cpm": 1.418014,
"cpp": 1.468431,
"frequency": 1.035555,
"uniqueClicks": 3,
"uniqueCtr": 0.047832,
"costPerUniqueClick": 3.07,
"inlineLinkClicks": 0,
"costPerInlineLinkClick": 0,
"outboundClicks": 0,
"costPerOutboundClick": 0,
"websiteCtr": [],
"accountCurrency": "USD",
"accountName": "John Doe",
"accountId": "274948331"
},
"name": "API Post - DE6gpw8kxlonHy6eb7Lo - 2025-03-30T17:11:26",
"previewLink": "https://fb.me/22Cn31wXlzhxOC1",
"spend": 9.21,
"startDate": "2025-03-30T17:11:32.000Z",
"status": "ACTIVE",
"targeting": {
"ageMax": 65,
"ageMin": 18,
"geoLocations": {
"countries": ["US"],
"locationTypes": ["home", "recent"]
},
"interests": [
{
"id": "6003195554098",
"name": "Rhythm and blues music"
}
]
}
}
},
{
"ad": {
"accountId": "274948331",
"adId": "6685225314301",
"budgetRemaining": 0,
"created": "2025-03-30T18:36:39-0700",
"creativeId": "628434386637341",
"dailyBudget": 0,
"deliveryStatus": "PAUSED",
"endDate": "2025-04-03T22:30:00.000Z",
"fbPostId": "106638148652329_672633202087921",
"goal": {
"title": "Get More Engagement",
"description": "This goal seeks to increase engagement while ensuring that the ad reaches the maximum number of unique users. It balances visibility with engagement, showing the ad to as many different people as possible who may interact with it.",
"type": "engagement"
},
"isComplete": false,
"lifetimeBudget": 0,
"metrics": {},
"name": "API Post 14 - 106638148652329_672633202087926 - 2025-03-31T01:36:32",
"previewLink": "https://fb.me/2nPlTIZEpzrCnY1",
"spend": 0,
"startDate": "2025-03-31T01:36:37.000Z",
"status": "PAUSED",
"targeting": {
"ageMax": 65,
"ageMin": 18,
"geoLocations": {
"countries": ["US"],
"locationTypes": ["home", "recent"]
},
"interests": [
{
"id": "6003195554098",
"name": "Rhythm and blues music"
}
]
}
}
}
],
"count": 2
}
{
"action": "get ads",
"status": "error",
"code": 370,
"message": "Error getting ads. Please try again or contact us if the issue persists."
}
⌘I
