curl -G \
-d 'fields=name,success_count,error_count,is_completed' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/<REQUEST_SET_ID>
fields, such as fields=id,owner_id,name,total_count,success_count,error_count,is_completed.| Name | Description |
|---|---|
idtype: int | Shown by default. The id of current async request set. |
owner_idtype: int | Shown by default. Which object owns this async request set. For async requests on ads, owner_id is the account id. |
nametype: string | Shown by default. Name of this async request set. |
is_completedtype: boolean | Shown by default. Async requests in this set complete |
total_counttype: int | Not shown by default. Total requests count of this request set |
initial_counttype: int | Not shown by default. Number of requests not yet served. |
in_progress_counttype: int | Not shown by default. Number of requests in progress. |
success_counttype: int | Not shown by default. Number of requests finished and successful. |
error_counttype: int | Not shown by default. Number of requests finished and failed. |
canceled_counttype: int | Not shown by default. Number of requests canceled by user |
notification_uritype: string | Not shown by default. Notification URI for this async request set. |
notification_modetype: string | Not shown by default. Way to receive notification. Valid values include:
|
curl -G \
-d 'fields=id,status' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/<REQUEST_SET_ID>/requests
initial – Not processed yet.in_progress – Request is processingsuccess – Request finished and succeeds.error – Request finished and failedcanceled – Request canceled by userfields, such as fields=id,scope_object_id,status,result,input,async_request_set.| Name | Description |
|---|---|
idtype: int | Shown by default. Individual async request ID |
scope_object_idtype: int | Shown by default. Parent id of object this request creates. If you create an ad, this is ad set ID for the new ad. |
statustype: string | Shown by default. Status of this async request. Options:
|
resulttype: array | Not shown by default. If request is finished, shows result of the request. On success, the result is the same as a non-async request. For example, if you create an ad, the result for each request is the ID of the new ad. For errors, it will be array of:
|
inputtype: object | Not shown by default. Original input for this async request. If you create an ad, the input is adgroup_spec. |
async_request_settype: object | Not shown by default. Async request set that contains this individual request |
curl -G \
-d 'fields=id,status' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/<REQUEST_SET_ID>/requests
curl -G \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/act_<AD_ACCOUNT_ID>/asyncadrequestsets
is_completed. If is_completed=true, you see only completed async request set.curl -G \
-d 'fields=id,status' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/<AD_SET_ID>/asyncadrequests
https://graph.facebook.com/<API_VERSION>/<REQUEST_SET_ID>/requests API.name, notification_uri and notification_mode for an async request set.curl \
-F 'name=New Name' \
-F 'notification_mode=OFF' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/<REQUEST_SET_ID>
true on successful update. You can only change notification_uri and notification_mode before the notification is sent.curl -X DELETE \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/<REQUEST_ID>
true on successful cancellation. You can also cancel unprocessed requests in the async request set:curl -X DELETE \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/<REQUEST_SET_ID>
true on successful cancellation.//pretty=true for command line readable output
curl -G \
-d "id=6012384857989" \
-d "pretty=true" \
-d "access_token=_____" \
"https://graph.facebook.com/v25.0/"
{
"id": "6012384857989",
"owner_id": 12345,
"name": "testasyncset",
"is_completed": true
}
curl -G \
-d "id=6012384857989" \
-d "pretty=true" \
-d "fields=result" \
-d "access_token=_____" \
"https://graph.facebook.com/v25.0/requests"
{
"data": [
{
"result": {
"id": "6012384860989"
},
"id": "6012384858389"
},
{
"result": {
"id": "6012384858789"
},
"id": "6012384858189"
}
],
"paging": {
"cursors": {
"after": "___",
"before": "___"
}
}
}
curl -G \
-d "is_completed=1" \
-d "pretty=true" \
-d "access_token=___" \
"https://graph.facebook.com/v25.0/act_71597454/asyncadrequestsets"
{
"data": [
{
"id": "6012384253789",
"owner_id": 71597454,
"name": "testasyncset",
"is_completed": true
},
],
"paging": {
"cursors": {
"after": "___",
"before": "___"
}
}
}
curl -G \
-d "status=SUCCESS,ERROR" \
-d "pretty=true" \
-d "access_token=___" \
"https://graph.facebook.com/v25.0/6008248529789/asyncadrequests"
{
"data": [
{
"id": "6012384951789",
"scope_object_id": 6008248529789,
"status": "SUCCESS"
},
],
"paging": {
"cursors": {
"after": "___",
"before": "___"
}
}
}
curl -F 'access_token=______'
-F 'test1=@./test1.jpg'
-F 'batch=[
{
"method": "POST",
"name": "create_adimage",
"relative_url": "<API_VERSION>/act_187687683/adimages",
"attached_files": "test1"
},
{
"method": "POST",
"name": "create_creative",
"relative_url": "<API_VERSION>/act_187687683/adcreatives",
"attached_files": "test1",
"body": "name=sample creative&object_story_spec={\"link_data\": {\"image_hash\": \"{result=create_adimage:$.images.*.hash}\", \"link\": \"https://www.test12345.com\", \"message\": \"this is a sample message\"}, \"page_id\":\"12345678\"}°rees_of_freedom_spec={\"creative_features_spec\": {\"standard_enhancements\": {\"enroll_status\": \"OPT_OUT\"}}}"
},
{
"method": "POST",
"relative_url": "<API_VERSION>/act_187687683/ads",
"body": "adset_id=6004163746239&redownload=1&status=PAUSED&optimization_goal=REACH&billing_event=IMPRESSIONS&&creative={\"creative_id\":\"{result=create_creative:$.id}\"}&targeting={\"countries\":[\"US\"]}&name=test1"
},
{
"method": "POST",
"relative_url": "<API_VERSION>/act_187687683/ads",
"body": "adset_id=6004163746239&redownload=1&status=PAUSED&optimization_goal=REACH&billing_event=IMPRESSIONS&&creative={\"creative_id\":\"{result=create_creative:$.id}\"}&targeting={\"countries\":[\"US\"]}&name=test2"
},
{
"method": "POST",
"relative_url": "<API_VERSION>/act_187687683/ads",
"body": "adset_id=6004163746239&redownload=1&status=PAUSED&optimization_goal=REACH&billing_event=IMPRESSIONS&&creative={\"creative_id\":\"{result=create_creative:$.id}\"}&targeting={\"countries\":[\"US\"]}&name=test3"
}
]' https://graph.facebook.com/
curl -F 'access_token=____'
-F 'batch=[
{
"method": "POST",
"relative_url": "<API_VERSION>/6004251715639",
"body": "redownload=1&name=new name"
},
{
"method": "POST",
"relative_url": <API_VERSION>/v6004251716039",
"body": "redownload=1&name=new name"
},
{
"method": "POST",
"relative_url": "<API_VERSION>/6004251715839",
"body": "redownload=1&name=new name"
}
]' https://graph.facebook.com
redownload=1 in the relative URL, you get full ad details including the ad ID. This help identify which ads you updated.curl -F 'access_token=____'
-F 'batch=[
{
"method": "GET",
"relative_url": "<API_VERSION>/?ids=6003356308839,6004164369439&fields=<comma separated list of fields>"
},
{
"method": "GET",
"relative_url": "<API_VERSION>/6003356307839/ads&fields=<comma separated list of fields>"
},
{
"method": "GET",
"relative_url": "<API_VERSION>/act_187687683/ads?adset_ids=[6003356307839, 6004164259439]&fields=<comma separated list of fields>"
}
]' https://graph.facebook.com
curl -F 'access_token=____'
-F 'batch=[
{
"method": "GET",
"relative_url": "<API_VERSION>/act_19643108/insights?filtering=[{field:'ad.id',operator:'IN',value:[6003356308839,6004164369439]}]"
},
{
"method": "GET",
"relative_url": "<API_VERSION>/6003356308839/insights"
},
{
"method": "GET",
"relative_url": "<API_VERSION>/act_187687683/insights?filtering=[{field:'adset.id',operator:'IN',value:[6003356307839, 6004164259439]}]"
}
]' https://graph.facebook.com
6003356308839 and 6004164369439 are ad ids and 6003356307839 and 6004164259439 are ad set ids.act_<account_ID>/adgroupstats is not recommended as it may cause the request to timeout.curl -F 'access_token=____'
-F 'batch=[
{
"method": "GET",
"relative_url": "<API_VERSION>/act_600335/reachestimate?targeting_spec={'geo_locations': {'countries':['US']}}"
},
{
"method": "GET",
"relative_url": "<API_VERSION>/act_600335/reachestimate?targeting_spec={'geo_locations': {'countries':['FR']}}"
}
]' https://graph.facebook.com
curl \
-F "access_token=___" \
-F "name=asyncbatchreqs" \
-F "adbatch=<an array of requests>"\
"https://graph.facebook.com/v25.0/act_<AD_ACCOUNT_ID>/async_batch_requests"
HTTP POST requests as JSON arrays. Each request has:namerelative_url - portion of URL after graph.facebook.combodycurl \
-F "access_token=___" \
-F "name=batchapiexample" \
-F "adbatch=[
{
'name': 'create-campaign',
'relative_url': 'act_123456/campaigns',
'body': 'name%3DTest+Campaign%26objective%3DLINK_CLICKS%26status%3DPAUSED%26buying_type%3DAUCTION',
},
{
'name': 'create-adset',
'relative_url': 'act_123456/adsets',
'body': 'targeting%3D%7B%22geo_locations%22%3A%7B%22countries%22%3A%5B%22US%22%5D%7D%7D%26daily_budget%3D5000%26campaign_id%3D%7Bresult%3Dcreate-campaign%3A%24.id%7D%26bid_amount%3D2%26name%3DFirst%2BAd%2BSet%20Test%26billing_event%3DLINK_CLICKS',
},
]" \
https://graph.facebook.com/<API_VERSION>/act_123456/async_batch_requests
curl –G \
-d "access_token=___" \
-d "fields=<comma separated list of fields>" \
"https://graph.facebook.com/v25.0/<REQUEST_SET_ID>"
fields, such as fields=id,owner_id,name,total_count,success_count,error_count,is_completed| Name | Description |
|---|---|
idtype: int | Shown by default. id of current async request set. |
owner_idtype: int | Shown by default. Object that owns this async request set. If you create ads, owner_id is the ad account id. |
nametype: string | Shown by default. Name of this async request set |
is_completedtype: boolean | Shown by default. All async requests in set complete |
total_counttype: int | Not shown by default. Total requests count for this request set |
initial_counttype: int | Not shown by default. Number of requests not served yet |
in_progress_counttype: int | Not shown by default. Number of requests in progress |
success_counttype: int | Not shown by default. Number of requests finished and successful |
error_counttype: int | Not shown by default. Number of requests finished and failed |
canceled_counttype: int | Not shown by default. Number of requests canceled by user |
notification_uritype: string | Not shown by default. Notification URI for this async request set. |
notification_modetype: string | Not shown by default. Ways to receive notification. Valid values:
|
notification_resulttype: string | Not shown by default. Result of sending notification. |
notification_statustype: string | Not shown by default. Notification status: not_sent, sending, or sent |
curl –G \
-d "access_token=___" \
-d "fields=<comma separated list of fields>" \
"https://graph.facebook.com/v25.0/<REQUEST_SET_ID>/requests"
fields, such as fields=id,scope_object_id,status,result,input,async_request_set.| Name | Description |
|---|---|
idtype: int | Shown by default. ID of individual async request |
scope_object_idtype: int | Shown by default. Parent ID of the object this request creates. If you create ads, this is ad set ID for the new ad. |
statustype: string | Shown by default. Status of this async request:
|
resulttype: array | Not shown by default. If request finishes, show result.
For success, the result is same as
non-async API. For example, if you create an ad
creation, result is new ad ID.
For errors:
|
inputtype: object | Not shown by default. Original input for this request. If you create an ad, the input is adgroup_spec. |
async_request_settype: object | Not shown by default. Async request set containing this request. |
curl –G \
-d "access_token=___" \
"https://graph.facebook.com/v25.0/act_<AD_ACCOUNT_ID>/async_requests"
304 – Not Modified and no data is returned.If-None-Match GET still counts against rate limits for your app.curl -i "https://graph.beta.facebook.com/me/adaccounts?access_token=___"
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Cache-Control: private, no-cache, no-store, must-revalidate
Content-Type: text/javascript; charset=UTF-8
ETag: "7776cdb01f44354af8bfa4db0c56eebcb1378975"
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Pragma: no-cache
X-FB-Rev: 495685
X-FB-Server: 10.30.149.204
X-FB-Debug: CWbHcogdwUE8saMv6ML+8FacXFrE8ufhjjwxU2dQWaA=
X-Cnection: close
Date: Mon, 16 Jan 2012 12:07:44 GMT
Content-Length: 3273
{"data":[{"id":"act.......
"7776cdb01f44354af8bfa4db0c56eebcb1378975", note that the ETag includes the quotes (").curl -i -H "If-None-Match: \"7776cdb01f44354af8bfa4db0c56eebcb1378975\"" "https://graph.beta.facebook.com/me/adaccounts?access_token=___"
HTTP/1.1 304 Not Modified
Access-Control-Allow-Origin: *
Cache-Control: private, no-cache, no-store, must-revalidate
Content-Type: text/javascript; charset=UTF-8
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Pragma: no-cache
X-FB-Rev: 495685
X-FB-Server: 10.30.177.190
X-FB-Debug: ImBhat3k07Nez5FvuS2lPWU0U2xxmxD4B3k9ua4Sk7Q=
X-Cnection: close
Date: Mon, 16 Jan 2012 12:09:17 GMT
Content-Length: 0
304 Not Modified response. If the data had changed a normal API response would be returned.curl -i "curl -F 'access_token=___' -F 'batch=[
{"method":"GET", "relative_url": "?ids=6003356308839,6004164369439" },
{"method":"GET", "relative_url": "act_12345678/ads?campaign_ids=[6003356307839, 6004164259439]"}]'
https://graph.facebook.com"
...{"name":"ETag","value":"\"21d371640127490b2ed0387e8af3f0f8c9eff012\""}...
...{"name":"ETag","value":"\"410e53bb257f116e8716e4ebcc76df1c567b87f4\""}...
"21d371640127490b2ed0387e8af3f0f8c9eff012" and "410e53bb257f116e8716e4ebcc76df1c567b87f4" note that the ETag includes the quotes (").curl -F 'access_token=___' -F 'batch=[
{"method":"GET", "headers":["If-None-Match: \"21d371640127490b2ed0387e8af3f0f8c9eff012\""], "relative_url": "?ids=6003356308839,6004164369439" },
{"method":"GET", "headers":["If-None-Match: \"410e53bb257f116e8716e4ebcc76df1c567b87f4\""], "relative_url": "act_12345678/ads?campaign_ids=[6003356307839, 6004164259439]"}]'
https://graph.facebook.com
[{
"code": 304,
.
.
.
"body": null
},
{
"code": 304,
.
.
.
"body": null
}]
304 Not Modified response. If the data changed, we return a normal API response.