Resource Information
| Method | GET |
|---|---|
| URL | https://public-api.wordpress.com/rest/v1.3/batch/ |
| Requires authentication? | No |
Query Parameters
| Parameter | Type | Description |
|---|---|---|
| http_envelope | (bool) |
|
| pretty | (bool) |
|
| meta | (string) | Optional. Loads data from the endpoints found in the 'meta' part of the response. Comma-separated list. Example: meta=site,likes |
| fields | (string) | Optional. Returns specified fields only. Comma-separated list. Example: fields=ID,title |
| callback | (string) | An optional JSONP callback function. |
| urls | (array) | Array of endpoints to call |
Resource Errors
These are the possible errors returned by this endpoint.
| HTTP Code | Error Identifier | Error Message |
|---|---|---|
| 400 | invalid_input | Invalid request input |
Example
curl 'https://public-api.wordpress.com/rest/v1/batch/?urls\[\]=/sites/4/&urls\[\]=/sites/4/posts?number=1'
<?php
$options = array (
'http' =>
array (
'ignore_errors' => true,
),
);
$context = stream_context_create( $options );
$response = file_get_contents(
'https://public-api.wordpress.com/rest/v1/batch/?urls[]=/sites/4/&urls[]=/sites/4/posts?number=1',
false,
$context
);
$response = json_decode( $response );
?>
Response
{
"\/sites\/4\/": {
"ID": 4,
"name": "Matt on Not-WordPress",
"description": "Stuff and things.",
"URL": "https:\/\/matt.wordpress.com",
"jetpack": false,
"subscribers_count": 234460,
"lang": false,
"icon": {
"img": "https:\/\/secure.gravatar.com\/blavatar\/1dda380e30f5105e49d00ff16adc24a4",
"ico": "https:\/\/secure.gravatar.com\/blavatar\/1dda380e30f5105e49d00ff16adc24a4"
},
"logo": {
"id": 0,
"sizes": [],
"url": ""
},
"visible": null,
"is_private": false,
"is_following": false,
"meta": {
"links": {
"self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4",
"help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/help",
"posts": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/",
"comments": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/comments\/",
"xmlrpc": "https:\/\/matt.wordpress.com\/xmlrpc.php"
}
}
},
"\/sites\/4\/posts?number=1": {
"found": 2313,
"posts": [
{
"ID": 7721,
"site_ID": 4,
"author": {
"ID": 5,
"login": "matt",
"email": false,
"name": "Matt",
"first_name": "Matt",
"last_name": "Mullenweg",
"nice_name": "matt",
"URL": "http:\/\/matt.wordpress.com",
"avatar_URL": "https:\/\/1.gravatar.com\/avatar\/767fc9c115a1b989744c755db47feb60?s=96&d=retro&r=G",
"profile_URL": "http:\/\/en.gravatar.com\/matt",
"site_ID": 4
},
"date": "2016-06-08T20:43:21+00:00",
"modified": "2016-06-08T20:43:22+00:00",
"title": "Just below the clouds, near Stockholm",
"URL": "https:\/\/matt.wordpress.com\/2016\/06\/08\/just-below-the-clouds-near-stockholm\/",
"short_URL": "http:\/\/wp.me\/p4-20x",
"content": "<p><a href=\"http:\/\/matt.files.wordpress.com\/2016\/06\/fullsizerender.jpg\"><img src=\"https:\/\/matt.files.wordpress.com\/2016\/06\/fullsizerender.jpg?w=768&h=576\" alt=\"\" width=\"768\" height=\"576\" class=\"alignnone size-full wp-image-7722\" \/><\/a><\/p>\n",
"excerpt": "",
"slug": "just-below-the-clouds-near-stockholm",
"guid": "https:\/\/matt.wordpress.com\/?p=7721",
"status": "publish",
"sticky": false,
"password": "",
"parent": false,
"type": "post",
"comments_open": true,
"pings_open": true,
"likes_enabled": true,
"sharing_enabled": true,
"comment_count": 5,
"like_count": 65,
"i_like": false,
"is_reblogged": false,
"is_following": false,
"global_ID": "01f1a7d719a994ddf4da197d36d59a78",
"featured_image": "",
"post_thumbnail": null,
"format": "image",
"geo": false,
"menu_order": 0,
"publicize_URLs": [],
"tags": {},
"categories": {
"Moblog": {
"ID": 26114,
"name": "Moblog",
"slug": "moblog",
"description": "",
"post_count": 2260,
"parent": 0,
"meta": {
"links": {
"self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/categories\/slug:moblog",
"help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/categories\/slug:moblog\/help",
"site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4"
}
}
}
},
"attachments": {
"7722": {
"ID": 7722,
"URL": "https:\/\/matt.files.wordpress.com\/2016\/06\/fullsizerender.jpg",
"guid": "http:\/\/matt.files.wordpress.com\/2016\/06\/fullsizerender.jpg",
"mime_type": "image\/jpeg",
"width": 4032,
"height": 3024
}
},
"metadata": [
{
"id": "66494",
"key": "geo_accuracy",
"value": "40"
},
{
"id": "66492",
"key": "geo_latitude",
"value": "59.818786"
},
{
"id": "66493",
"key": "geo_longitude",
"value": "17.958964"
},
{
"id": "66509",
"key": "_wpas_done_2191330",
"value": "1"
},
{
"id": "66503",
"key": "_wpas_done_4543371",
"value": "1"
},
{
"id": "66506",
"key": "_wpas_done_4543378",
"value": "1"
},
{
"id": "66512",
"key": "_wpas_done_590",
"value": "1"
},
{
"id": "66499",
"key": "_wpas_done_591",
"value": "1"
},
{
"id": "66514",
"key": "_wpas_done_592",
"value": "1"
}
],
"meta": {
"links": {
"self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7721",
"help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7721\/help",
"site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4",
"replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7721\/replies\/",
"likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7721\/likes\/"
}
},
"current_user_can": {
"publish_post": false,
"delete_post": false,
"edit_post": false
},
"capabilities": {
"publish_post": false,
"delete_post": false,
"edit_post": false
}
}
]
}
}