GET /batch/

Run several GET endpoints and return them as an array

Resource URL

Type URL and Format
GET https://public-api.wordpress.com/rest/v1/batch/

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

Example

cURL

curl 'https://public-api.wordpress.com/rest/v1/batch/?urls[]=/sites/4/&urls[]=/sites/4/posts?number=1&pretty=1'

PHP

<?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&pretty=1',
  false,
  $context
);
$response = json_decode( $response );

?>

Response Body

{
    "\/sites\/4\/": {
        "ID": 4,
        "name": "Matt on Not-WordPress",
        "description": "Stuff and things.",
        "URL": "http:\/\/matt.wordpress.com",
        "jetpack": false,
        "subscribers_count": 206376,
        "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": 2169,
        "posts": [
            {
                "ID": 6865,
                "site_ID": 4,
                "author": {
                    "ID": 5,
                    "login": "matt",
                    "email": false,
                    "name": "Matt",
                    "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": "2014-05-07T00:00:00+00:00",
                "modified": "2014-05-04T10:33:56+00:00",
                "title": "Ana Teresa Fernandez show in San Francisco",
                "URL": "http:\/\/matt.wordpress.com\/2014\/05\/07\/ana-teresa-fernandez-show-in-san-francisco\/",
                "short_URL": "http:\/\/wp.me\/p4-1MJ",
                "content": "<p><a href=\"http:\/\/matt.files.wordpress.com\/2014\/05\/ana-teresa-fernandez-show-in-san-francisco.jpg\"><img class=\"alignnone size-full wp-image-6866\" src=\"https:\/\/matt.files.wordpress.com\/2014\/05\/ana-teresa-fernandez-show-in-san-francisco.jpg?w=584\" alt=\"ana-teresa-fernandez-show-in-san-francisco\"   \/><\/a><\/p>\n",
                "excerpt": "",
                "slug": "ana-teresa-fernandez-show-in-san-francisco",
                "guid": "http:\/\/matt.wordpress.com\/2014\/05\/07\/ana-teresa-fernandez-show-in-san-francisco\/",
                "status": "publish",
                "sticky": false,
                "password": "",
                "parent": false,
                "type": "post",
                "comments_open": true,
                "pings_open": true,
                "likes_enabled": true,
                "sharing_enabled": true,
                "gplusauthorship_enabled": true,
                "comment_count": 5,
                "like_count": 103,
                "i_like": 0,
                "is_reblogged": 0,
                "is_following": 0,
                "global_ID": "2c77f74a057e9de8cc9db553051579fc",
                "featured_image": "",
                "post_thumbnail": "",
                "format": "image",
                "geo": false,
                "publicize_URLs": [

                ],
                "tags": {

                },
                "categories": {
                    "Moblog": {
                        "ID": 26114,
                        "name": "Moblog",
                        "slug": "moblog",
                        "description": "",
                        "post_count": 2116,
                        "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": {
                    "6866": {
                        "ID": 6866,
                        "URL": "http:\/\/matt.files.wordpress.com\/2014\/05\/ana-teresa-fernandez-show-in-san-francisco.jpg",
                        "guid": "http:\/\/matt.files.wordpress.com\/2014\/05\/ana-teresa-fernandez-show-in-san-francisco.jpg",
                        "mime_type": "image\/jpeg",
                        "width": 1536,
                        "height": 1152
                    }
                },
                "metadata": false,
                "meta": {
                    "links": {
                        "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/6865",
                        "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/6865\/help",
                        "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4",
                        "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/6865\/replies\/",
                        "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/6865\/likes\/"
                    }
                },
                "featured_media": {

                }
            }
        ]
    }
}