GET /batch/

Run several GET endpoints and return them as an array.

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)
false:
(default)
true:
Some environments (like in-browser JavaScript or Flash) block or divert responses with a non-200 HTTP status code. Setting this parameter will force the HTTP status code to always be 200. The JSON response is wrapped in an "envelope" containing the "real" HTTP status code and headers.
pretty (bool)
false:
(default)
true:
Output pretty JSON
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": "http:\/\/matt.blog",
        "jetpack": false,
        "subscribers_count": 235037,
        "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": 2323,
        "posts": [
            {
                "ID": 7768,
                "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": 492382
                },
                "date": "2016-09-17T21:22:33+00:00",
                "modified": "2016-09-18T00:52:51+00:00",
                "title": "Automattic, in 2016, in Whistler",
                "URL": "http:\/\/matt.blog\/2016\/09\/17\/automattic-in-2016-in-whistler\/",
                "short_URL": "http:\/\/wp.me\/p4-21i",
                "content": "<p><a href=\"https:\/\/matt.files.wordpress.com\/2016\/09\/2016-09-17-9579-l.jpg\"><img class=\"alignnone size-full wp-image-7769\" src=\"https:\/\/matt.files.wordpress.com\/2016\/09\/2016-09-17-9579-l.jpg?w=5307&h=3538\" alt=\"2016-09-17-9579-l.jpg\" width=\"5307\" height=\"3538\" \/><\/a><\/p>\n<p>Thanks to <a href=\"https:\/\/odd.blog\/\">Donncha<\/a> for the photo!<\/p>\n",
                "excerpt": "<p>Thanks to Donncha for the photo!<\/p>\n",
                "slug": "automattic-in-2016-in-whistler",
                "guid": "http:\/\/matt.blog\/?p=7768",
                "status": "publish",
                "sticky": false,
                "password": "",
                "parent": false,
                "type": "post",
                "comments_open": true,
                "pings_open": true,
                "likes_enabled": true,
                "sharing_enabled": true,
                "comment_count": 21,
                "like_count": 220,
                "i_like": false,
                "is_reblogged": false,
                "is_following": false,
                "global_ID": "0769907f6165d31931ece9ca9c32b5cc",
                "featured_image": "",
                "post_thumbnail": null,
                "format": "standard",
                "geo": false,
                "menu_order": 0,
                "publicize_URLs": [],
                "tags": {
                    "a8cgm": {
                        "ID": 273554598,
                        "name": "a8cgm",
                        "slug": "a8cgm",
                        "description": "",
                        "post_count": 1,
                        "meta": {
                            "links": {
                                "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/tags\/slug:a8cgm",
                                "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/tags\/slug:a8cgm\/help",
                                "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4"
                            }
                        }
                    },
                    "Automattic": {
                        "ID": 55574,
                        "name": "Automattic",
                        "slug": "automattic",
                        "description": "",
                        "post_count": 4,
                        "meta": {
                            "links": {
                                "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/tags\/slug:automattic",
                                "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/tags\/slug:automattic\/help",
                                "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4"
                            }
                        }
                    }
                },
                "categories": {
                    "Moblog": {
                        "ID": 26114,
                        "name": "Moblog",
                        "slug": "moblog",
                        "description": "",
                        "post_count": 2270,
                        "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": {
                    "7769": {
                        "ID": 7769,
                        "URL": "https:\/\/matt.files.wordpress.com\/2016\/09\/2016-09-17-9579-l.jpg",
                        "guid": "http:\/\/matt.files.wordpress.com\/2016\/09\/2016-09-17-9579-l.jpg",
                        "mime_type": "image\/jpeg",
                        "width": 5307,
                        "height": 3538
                    }
                },
                "metadata": [
                    {
                        "id": "66849",
                        "key": "_wpas_done_2191330",
                        "value": "1"
                    },
                    {
                        "id": "66843",
                        "key": "_wpas_done_4543371",
                        "value": "1"
                    },
                    {
                        "id": "66846",
                        "key": "_wpas_done_4543378",
                        "value": "1"
                    },
                    {
                        "id": "66852",
                        "key": "_wpas_done_590",
                        "value": "1"
                    },
                    {
                        "id": "66840",
                        "key": "_wpas_done_591",
                        "value": "1"
                    },
                    {
                        "id": "66854",
                        "key": "_wpas_done_592",
                        "value": "1"
                    }
                ],
                "meta": {
                    "links": {
                        "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7768",
                        "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7768\/help",
                        "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4",
                        "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7768\/replies\/",
                        "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7768\/likes\/"
                    }
                },
                "current_user_can": {
                    "publish_post": false,
                    "delete_post": false,
                    "edit_post": false
                },
                "capabilities": {
                    "publish_post": false,
                    "delete_post": false,
                    "edit_post": false
                }
            }
        ]
    }
}