curl \
-H "Authorization: Bearer API_KEY" \
-X GET "https://api.ayrshare.com/api/ads/facebook/audiences?accountId=1234567890"
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/audiences?accountId=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/audiences?accountId=1234567890', headers=headers)
print(r.json())
{
"status": "success",
"audiences": [
{
"id": "23851234567890123",
"name": "Site visitors 30d",
"type": "website",
"size": { "lower": 12000, "upper": 14100 },
"status": { "ready": true, "code": 200, "description": "This audience is ready for use." },
"created": "2026-10-20T09:12:00.000Z"
},
{
"id": "23851234567890456",
"name": "Like site visitors",
"type": "lookalike",
"size": null,
"status": { "ready": false, "code": 300, "description": "This audience is still being populated." },
"created": "2026-10-28T16:40:00.000Z"
}
],
"meta": { "pagination": { "hasMore": false } }
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "accountId is required."
}
{
"action": "ads",
"status": "error",
"code": 370,
"message": "Error getting audiences. Please try again.",
"details": "Meta's reason"
}
Facebook Ads
Đối tượng
Liệt kê các đối tượng tùy chỉnh trên tài khoản quảng cáo Facebook, kèm loại, quy mô và việc một lượt boost đã có thể nhắm tới từng đối tượng hay chưa.
GET
/
ads
/
facebook
/
audiences
curl \
-H "Authorization: Bearer API_KEY" \
-X GET "https://api.ayrshare.com/api/ads/facebook/audiences?accountId=1234567890"
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/audiences?accountId=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/audiences?accountId=1234567890', headers=headers)
print(r.json())
{
"status": "success",
"audiences": [
{
"id": "23851234567890123",
"name": "Site visitors 30d",
"type": "website",
"size": { "lower": 12000, "upper": 14100 },
"status": { "ready": true, "code": 200, "description": "This audience is ready for use." },
"created": "2026-10-20T09:12:00.000Z"
},
{
"id": "23851234567890456",
"name": "Like site visitors",
"type": "lookalike",
"size": null,
"status": { "ready": false, "code": 300, "description": "This audience is still being populated." },
"created": "2026-10-28T16:40:00.000Z"
}
],
"meta": { "pagination": { "hasMore": false } }
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "accountId is required."
}
{
"action": "ads",
"status": "error",
"code": 370,
"message": "Error getting audiences. Please try again.",
"details": "Meta's reason"
}
Liệt kê các đối tượng tùy chỉnh trên tài khoản quảng cáo Facebook: khách truy cập trang web, người đã tương tác với một Trang, một tài khoản Instagram hoặc một video, đối tượng tương tự (lookalike) và danh sách khách hàng của riêng bạn. Dùng các id trong
targeting.audiences hoặc targeting.excludedAudiences khi bạn boost một bài viết.
- Các đối tượng tạo trong Meta Ads Manager cũng được liệt kê, không chỉ những đối tượng tạo qua Ayrshare.
status.readylàtruekhi Meta đã điền xong đối tượng và một lượt boost có thể nhắm tới nó. Một đối tượng mới chưa sẵn sàng cho đến khi Meta khớp được ít nhất 100 người, việc này có thể mất vài giờ với đối tượng trang web hoặc tương tác và tới 48 giờ với danh sách khách hàng.sizelà ước tính riêng của Meta, dưới dạng cận dưới và cận trên. Giá trị lànullkhi Meta chưa có ước tính, ví dụ khi đối tượng vẫn đang được điền.- Kết quả không được lưu đệm: quy mô và trạng thái sẵn sàng của đối tượng thay đổi trong khi nó được điền.
Tham số Header
Tham số truy vấn
Tài khoản quảng cáo cần liệt kê đối tượng, lấy từ tài khoản quảng cáo, có hoặc không có tiền tố
act_.Số đối tượng tối đa trả về trong một trang, từ 1 đến 1000. Mặc định là 100; số lớn hơn sẽ trả về 1000.
Khi phản hồi có
meta.pagination.hasMore: true, hãy gửi giá trị meta.pagination.next của nó vào đây để lấy trang tiếp theo. Giữ nguyên các tham số khác: một giá trị next từ yêu cầu khác sẽ trả về code: 101.Phản hồi
Mỗi đối tượng có:id: id đối tượng dùng khi boost, thêm người hoặc xóa.name: tên hiển thị trong Ads Manager.type:website,engagement,lookalike,customerList, hoặcothercho loại đối tượng mà Ayrshare không tạo.size:{ lower, upper }, ước tính của Meta, hoặcnull.status:{ ready, code, description }.readylàtruekhi một lượt boost có thể nhắm tới đối tượng ngay bây giờ;codevàdescriptionlà trạng thái phân phối của Meta.created: thời điểm tạo đối tượng, theo ISO 8601, hoặcnull.
meta.pagination.hasMore là true và meta.pagination.next được đặt. Gửi lại cùng yêu cầu với next bằng giá trị đó để lấy trang tiếp theo.
curl \
-H "Authorization: Bearer API_KEY" \
-X GET "https://api.ayrshare.com/api/ads/facebook/audiences?accountId=1234567890"
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/audiences?accountId=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/audiences?accountId=1234567890', headers=headers)
print(r.json())
{
"status": "success",
"audiences": [
{
"id": "23851234567890123",
"name": "Site visitors 30d",
"type": "website",
"size": { "lower": 12000, "upper": 14100 },
"status": { "ready": true, "code": 200, "description": "This audience is ready for use." },
"created": "2026-10-20T09:12:00.000Z"
},
{
"id": "23851234567890456",
"name": "Like site visitors",
"type": "lookalike",
"size": null,
"status": { "ready": false, "code": 300, "description": "This audience is still being populated." },
"created": "2026-10-28T16:40:00.000Z"
}
],
"meta": { "pagination": { "hasMore": false } }
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "accountId is required."
}
{
"action": "ads",
"status": "error",
"code": 370,
"message": "Error getting audiences. Please try again.",
"details": "Meta's reason"
}