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": 236163,
        "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": 2356,
        "posts": [
            {
                "ID": 7925,
                "site_ID": 4,
                "author": {
                    "ID": 5,
                    "login": "matt",
                    "email": false,
                    "name": "Matt",
                    "first_name": "Matt",
                    "last_name": "Mullenweg",
                    "nice_name": "matt",
                    "URL": "https:\/\/matt.blog\/",
                    "avatar_URL": "https:\/\/1.gravatar.com\/avatar\/767fc9c115a1b989744c755db47feb60?s=96&d=retro&r=G",
                    "profile_URL": "https:\/\/en.gravatar.com\/matt",
                    "ip_address": false,
                    "site_ID": 4,
                    "site_visible": true
                },
                "date": "2018-04-09T04:06:25+00:00",
                "modified": "2018-04-09T04:06:26+00:00",
                "title": "WrestleMania 34 in New Orleans",
                "URL": "http:\/\/matt.blog\/2018\/04\/09\/wrestlemania-34-in-new-orleans\/",
                "short_URL": "https:\/\/wp.me\/p4-23P",
                "content": "<p><a href=\"http:\/\/matt.files.wordpress.com\/2018\/04\/img_4870.jpg\"><img data-attachment-id=\"7926\" data-permalink=\"http:\/\/matt.blog\/2018\/04\/09\/wrestlemania-34-in-new-orleans\/img-4870\/\" data-orig-file=\"https:\/\/matt.files.wordpress.com\/2018\/04\/img_4870.jpg?w=840&h=456\" data-orig-size=\"4192,2278\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;1.8&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;iPhone X&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1523209072&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4&quot;,&quot;iso&quot;:&quot;640&quot;,&quot;shutter_speed&quot;:&quot;0.0083333333333333&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"img 4870\" data-image-description=\"\" data-medium-file=\"https:\/\/matt.files.wordpress.com\/2018\/04\/img_4870.jpg?w=840&h=456?w=300\" data-large-file=\"https:\/\/matt.files.wordpress.com\/2018\/04\/img_4870.jpg?w=840&h=456?w=1024\" src=\"https:\/\/matt.files.wordpress.com\/2018\/04\/img_4870.jpg?w=840&h=456\" alt=\"\" width=\"840\" height=\"456\" class=\"alignnone size-full wp-image-7926\" srcset=\"https:\/\/matt.files.wordpress.com\/2018\/04\/img_4870.jpg?w=840&amp;h=456 840w, https:\/\/matt.files.wordpress.com\/2018\/04\/img_4870.jpg?w=1678&amp;h=912 1678w, https:\/\/matt.files.wordpress.com\/2018\/04\/img_4870.jpg?w=150&amp;h=82 150w, https:\/\/matt.files.wordpress.com\/2018\/04\/img_4870.jpg?w=300&amp;h=163 300w, https:\/\/matt.files.wordpress.com\/2018\/04\/img_4870.jpg?w=768&amp;h=417 768w, https:\/\/matt.files.wordpress.com\/2018\/04\/img_4870.jpg?w=1024&amp;h=556 1024w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><\/a><\/p>\n",
                "excerpt": "",
                "slug": "wrestlemania-34-in-new-orleans",
                "guid": "http:\/\/matt.blog\/?p=7925",
                "status": "publish",
                "sticky": false,
                "password": "",
                "parent": false,
                "type": "post",
                "comments_open": true,
                "pings_open": true,
                "likes_enabled": true,
                "sharing_enabled": true,
                "comment_count": 0,
                "like_count": 52,
                "i_like": false,
                "is_reblogged": false,
                "is_following": false,
                "global_ID": "bd50c090254eafd22e4723e71e19986c",
                "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": 2303,
                        "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": {
                    "7926": {
                        "ID": 7926,
                        "URL": "https:\/\/matt.files.wordpress.com\/2018\/04\/img_4870.jpg",
                        "guid": "http:\/\/matt.files.wordpress.com\/2018\/04\/img_4870.jpg",
                        "mime_type": "image\/jpeg",
                        "width": 4192,
                        "height": 2278
                    }
                },
                "metadata": [
                    {
                        "id": "68321",
                        "key": "_wpas_done_2191330",
                        "value": "1"
                    },
                    {
                        "id": "68316",
                        "key": "_wpas_done_4543371",
                        "value": "1"
                    },
                    {
                        "id": "68324",
                        "key": "_wpas_done_590",
                        "value": "1"
                    },
                    {
                        "id": "68313",
                        "key": "_wpas_done_591",
                        "value": "1"
                    },
                    {
                        "id": "68326",
                        "key": "_wpas_done_592",
                        "value": "1"
                    },
                    {
                        "id": "68317",
                        "key": "_wpas_path_publicize_failure",
                        "value": {
                            "errors": {
                                "keyring-request-error": [
                                    {
                                        "errors": {
                                            "http_request_failed": [
                                                "cURL error 28: Operation timed out after 5000 milliseconds with 0 bytes received"
                                            ]
                                        },
                                        "error_data": []
                                    }
                                ]
                            },
                            "error_data": []
                        }
                    }
                ],
                "meta": {
                    "links": {
                        "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7925",
                        "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7925\/help",
                        "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4",
                        "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7925\/replies\/",
                        "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7925\/likes\/"
                    }
                },
                "current_user_can": {
                    "publish_post": false,
                    "delete_post": false,
                    "edit_post": false
                },
                "capabilities": {
                    "publish_post": false,
                    "delete_post": false,
                    "edit_post": false
                }
            }
        ]
    }
}