curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music", {
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/interests?search=Rhythm%20and%20blues%20music', headers=headers)
print(r.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY"
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
var response = await client.GetAsync("https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music", nil)
req.Header.Add("Authorization", "Bearer API_KEY")
resp, _ := client.Do(req)
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class GetAdInterests {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music"))
.header("Authorization", "Bearer API_KEY")
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
require 'net/http'
require 'json'
uri = URI('https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music')
req = Net::HTTP::Get.new(uri)
req['Authorization'] = 'Bearer API_KEY'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
http.request(req)
}
puts res.body
{
"status": "success",
"interests": [
{
"id": "6003195554098",
"name": "Rhythm and blues music",
"topic": "News and entertainment",
"audienceSizeLowerBound": 669180255,
"audienceSizeUpperBound": 786955980
},
{
"id": "6003470511564",
"name": "Do it yourself (DIY)",
"topic": "Hobbies and activities",
"audienceSizeLowerBound": 418387661, // Lower bound of audience size
"audienceSizeUpperBound": 492023890 // Upper bound of audience size
},
{
"id": "6002926036121",
"name": "Italy",
"topic": "Travel, places and events",
"audienceSizeLowerBound": 279313350, // Lower bound of audience size
"audienceSizeUpperBound": 328472500 // Upper bound of audience size
}
],
"count": 3,
"lastUpdated": "2025-03-27T01:01:38.547Z",
"nextUpdate": "2025-03-27T01:12:38.547Z"
}
{
"status": "success",
"interests": [
{
"id": "6003269553527",
"name": "Nursing",
"audienceSizeLowerBound": 91340120,
"audienceSizeUpperBound": 107420310
},
{
"id": "6003204427551",
"name": "Health care",
"audienceSizeLowerBound": 412880440,
"audienceSizeUpperBound": 485610770
}
],
"count": 2,
"specialAdCategories": ["EMPLOYMENT"],
"lastUpdated": "2026-09-11T01:01:38.547Z",
"nextUpdate": "2026-09-11T01:12:38.547Z"
}
{
"action": "get ad interests",
"status": "error",
"code": 368,
"message": "Error getting ad interests. Please try again or contact us if the issue persists."
}
Facebook Ads
Sở thích
Lấy các sở thích quảng cáo Facebook
GET
/
ads
/
facebook
/
interests
curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music", {
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/interests?search=Rhythm%20and%20blues%20music', headers=headers)
print(r.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY"
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
var response = await client.GetAsync("https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music", nil)
req.Header.Add("Authorization", "Bearer API_KEY")
resp, _ := client.Do(req)
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class GetAdInterests {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music"))
.header("Authorization", "Bearer API_KEY")
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
require 'net/http'
require 'json'
uri = URI('https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music')
req = Net::HTTP::Get.new(uri)
req['Authorization'] = 'Bearer API_KEY'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
http.request(req)
}
puts res.body
{
"status": "success",
"interests": [
{
"id": "6003195554098",
"name": "Rhythm and blues music",
"topic": "News and entertainment",
"audienceSizeLowerBound": 669180255,
"audienceSizeUpperBound": 786955980
},
{
"id": "6003470511564",
"name": "Do it yourself (DIY)",
"topic": "Hobbies and activities",
"audienceSizeLowerBound": 418387661, // Lower bound of audience size
"audienceSizeUpperBound": 492023890 // Upper bound of audience size
},
{
"id": "6002926036121",
"name": "Italy",
"topic": "Travel, places and events",
"audienceSizeLowerBound": 279313350, // Lower bound of audience size
"audienceSizeUpperBound": 328472500 // Upper bound of audience size
}
],
"count": 3,
"lastUpdated": "2025-03-27T01:01:38.547Z",
"nextUpdate": "2025-03-27T01:12:38.547Z"
}
{
"status": "success",
"interests": [
{
"id": "6003269553527",
"name": "Nursing",
"audienceSizeLowerBound": 91340120,
"audienceSizeUpperBound": 107420310
},
{
"id": "6003204427551",
"name": "Health care",
"audienceSizeLowerBound": 412880440,
"audienceSizeUpperBound": 485610770
}
],
"count": 2,
"specialAdCategories": ["EMPLOYMENT"],
"lastUpdated": "2026-09-11T01:01:38.547Z",
"nextUpdate": "2026-09-11T01:12:38.547Z"
}
{
"action": "get ad interests",
"status": "error",
"code": 368,
"message": "Error getting ad interests. Please try again or contact us if the issue persists."
}
Tìm kiếm các tùy chọn nhắm mục tiêu theo sở thích khả dụng của quảng cáo Facebook theo từ khóa.
Sử dụng endpoint này để tra cứu ID sở thích cho endpoint Boost Post.
Endpoint này giúp bạn khám phá các tùy chọn nhắm mục tiêu dựa trên sở thích cho quảng cáo Facebook, kèm theo ước tính quy mô đối tượng.
- ID sở thích có thể được sử dụng trong mảng
interestskhi boost bài đăng. - Kết quả được cache trong 10 phút.
- Sử dụng các từ khóa tìm kiếm cụ thể, liên quan để có kết quả tốt nhất.
- Facebook có thể trả về các kết quả khác nhau dựa trên ngành và khu vực của tài khoản quảng cáo của bạn.
- Các trường
audienceSizeLowerBoundvàaudienceSizeUpperBoundtrong phản hồi JSON cung cấp khoảng ước tính quy mô đối tượng cho sở thích và hữu ích cho việc nhắm mục tiêu. - Sử dụng
specialAdCategoriesđể chỉ trả về các sở thích mà Meta cho phép đối với một chiến dịch thuộc danh mục quảng cáo đặc biệt. Các yêu cầu có lọc cũng yêu cầuaccountId.
Tham số Header
Tham số Query
string
bắt buộc
Truy vấn tìm kiếm để lấy các sở thích quảng cáo Facebook.Đừng quên escape (mã hóa URL) truy vấn tìm kiếm, ví dụ
Rhythm%20and%20blues%20music.array
Giới hạn kết quả trong các sở thích mà Meta cho phép một chiến dịch thuộc danh mục quảng cáo đặc biệt nhắm mục tiêu. Hãy sử dụng tham số này trước khi boost một bài đăng về nhà ở, việc làm, tài chính hoặc chính trị, để bạn chọn được các ID sở thích mà quảng cáo thực sự sẽ được phê duyệt.Các giá trị sau được hỗ trợ, khớp với tham số cùng tên của Boost Post:
housingemploymentfinancial_product_services—financial_products_servicesvàcreditđược chấp nhận là các cách viết tương đương và quy về cùng một danh mụcissues_elections_politicsnone— được chấp nhận để đối xứng với Boost Post, nơi nó có nghĩa là “không thuộc danh mục quảng cáo đặc biệt nào”. Nó được gửi đến Meta dưới dạngregulated_categories=["NONE"]:accountIdlà bắt buộc và một phản hồi thành công trả lại["NONE"]. Điều này không đảm bảo kết quả giống với một tìm kiếm không lọc; một từ chối từ Meta trả vềcode: 368. Hãy bỏ hẳnspecialAdCategoriesthay vì gửinonenếu bạn muốn một tìm kiếm không lọc thông thường.
400 và code: 101 liệt kê các giá trị được chấp nhận. Thông báo đó được viết theo dạng chữ hoa của Meta và cũng nêu tên các cách viết thay thế ở trên, nên nó hiển thị là NONE, HOUSING, FINANCIAL_PRODUCTS_SERVICES, EMPLOYMENT, ISSUES_ELECTIONS_POLITICS, FINANCIAL_PRODUCT_SERVICES, CREDIT — vẫn là các danh mục được liệt kê ở đây, không phải danh mục bổ sung. Boost Post trả về thông báo giống hệt. Một giá trị rỗng, như trong ?specialAdCategories=, bị từ chối theo cùng cách.Truyền nhiều danh mục bằng cách lặp lại tham số, ví dụ ?search=nursing&specialAdCategories=employment&specialAdCategories=housing. Dạng ngoặc vuông ?specialAdCategories[]=employment&specialAdCategories[]=housing cũng hoạt động. Một chuỗi phân tách bằng dấu phẩy như ?specialAdCategories=employment,housing không được hỗ trợ và bị từ chối với lỗi 400 và code: 101. Tất cả các danh mục được yêu cầu đều được gửi đến Meta trong một lần tìm kiếm. Ayrshare trả về kết quả của Meta và không tính toán hay đảm bảo phần giao của các sở thích đủ điều kiện một cách độc lập. Lặp lại một danh mục, hoặc gửi hai cách viết của cùng một danh mục, sẽ được gộp thành một danh mục duy nhất.Khi bạn cung cấp nhiều hơn một danh mục, trường specialAdCategories được trả lại trong phản hồi sẽ được sắp xếp theo thứ tự bảng chữ cái thay vì theo thứ tự bạn đã gửi.Bỏ hẳn specialAdCategories thì endpoint hoạt động đúng như trước đây: một tìm kiếm không lọc, không cần accountId, và cùng cấu trúc phản hồi.string
Bắt buộc khi
specialAdCategories được cung cấp, và bị bỏ qua trong trường hợp còn lại. ID của
tài khoản quảng cáo Facebook dùng để tìm kiếm các sở thích, không có tiền tố act_ — cùng giá trị
mà Boost Post nhận. Lấy nó từ endpoint ad
accounts. Nó phải là số; tiền tố act_ ở đầu được chấp nhận
và bị loại bỏ, còn bất kỳ giá trị nào khác sẽ bị từ chối với lỗi 400 và code: 101.Meta chỉ cung cấp tìm kiếm sở thích theo danh mục trên một tài khoản quảng cáo, nên một yêu cầu
cung cấp
specialAdCategories mà không có accountId sẽ bị từ chối với lỗi 400 và code: 101
trước khi bất kỳ tìm kiếm nào được chạy. Một yêu cầu không có specialAdCategories không thay đổi
và vẫn không cần accountId.number
mặc định:100
Giới hạn số lượng sở thích quảng cáo được trả về.
Một phản hồi có lọc trả lại các danh mục đã áp dụng trong trường
specialAdCategories, để bạn có
thể xác nhận kết quả đã được thu hẹp theo tiêu chí nào. Một phản hồi không lọc bỏ hẳn trường đó
thay vì trả về giá trị rỗng. Kết quả có lọc cũng không có trường topic trên mỗi sở thích, vì tìm
kiếm theo danh mục của Meta không trả về nó — hãy đọc name thay thế. Một tìm kiếm không có sở
thích đủ điều kiện nào trả về 200 với mảng interests rỗng và count: 0, không phải lỗi, và
một tìm kiếm có lọc không bao giờ quay về kết quả không lọc.curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music", {
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/interests?search=Rhythm%20and%20blues%20music', headers=headers)
print(r.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY"
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
var response = await client.GetAsync("https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music", nil)
req.Header.Add("Authorization", "Bearer API_KEY")
resp, _ := client.Do(req)
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class GetAdInterests {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music"))
.header("Authorization", "Bearer API_KEY")
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
require 'net/http'
require 'json'
uri = URI('https://api.ayrshare.com/api/ads/facebook/interests?search=Rhythm%20and%20blues%20music')
req = Net::HTTP::Get.new(uri)
req['Authorization'] = 'Bearer API_KEY'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
http.request(req)
}
puts res.body
{
"status": "success",
"interests": [
{
"id": "6003195554098",
"name": "Rhythm and blues music",
"topic": "News and entertainment",
"audienceSizeLowerBound": 669180255,
"audienceSizeUpperBound": 786955980
},
{
"id": "6003470511564",
"name": "Do it yourself (DIY)",
"topic": "Hobbies and activities",
"audienceSizeLowerBound": 418387661, // Lower bound of audience size
"audienceSizeUpperBound": 492023890 // Upper bound of audience size
},
{
"id": "6002926036121",
"name": "Italy",
"topic": "Travel, places and events",
"audienceSizeLowerBound": 279313350, // Lower bound of audience size
"audienceSizeUpperBound": 328472500 // Upper bound of audience size
}
],
"count": 3,
"lastUpdated": "2025-03-27T01:01:38.547Z",
"nextUpdate": "2025-03-27T01:12:38.547Z"
}
{
"status": "success",
"interests": [
{
"id": "6003269553527",
"name": "Nursing",
"audienceSizeLowerBound": 91340120,
"audienceSizeUpperBound": 107420310
},
{
"id": "6003204427551",
"name": "Health care",
"audienceSizeLowerBound": 412880440,
"audienceSizeUpperBound": 485610770
}
],
"count": 2,
"specialAdCategories": ["EMPLOYMENT"],
"lastUpdated": "2026-09-11T01:01:38.547Z",
"nextUpdate": "2026-09-11T01:12:38.547Z"
}
{
"action": "get ad interests",
"status": "error",
"code": 368,
"message": "Error getting ad interests. Please try again or contact us if the issue persists."
}