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": "https:\/\/matt.wordpress.com",
        "jetpack": false,
        "subscribers_count": 234010,
        "icon": {
            "img": "https:\/\/secure.gravatar.com\/blavatar\/1dda380e30f5105e49d00ff16adc24a4",
            "ico": "https:\/\/secure.gravatar.com\/blavatar\/cee3cad823afdeb7a7fefc50d7a264b9"
        },
        "logo": {
            "id": 0,
            "sizes": [],
            "url": ""
        },
        "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": 2306,
        "posts": [
            {
                "ID": 7689,
                "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-02-01T01:28:14+00:00",
                "modified": "2016-02-01T01:28:14+00:00",
                "title": "Four Waterfalls on Matt Davis Trail",
                "URL": "https:\/\/matt.wordpress.com\/2016\/02\/01\/four-waterfalls-on-matt-davis-trail\/",
                "short_URL": "http:\/\/wp.me\/p4-201",
                "content": "<p>Thanks to some much-needed rain in California, the streams are running and I saw probably a dozen small waterfalls on a 7-mile hike on the <a href=\"http:\/\/bahiker.com\/northbayhikes\/stinson.html\">Matt Davis trail, which starts near Stinson Beach<\/a>. Here are four of them:<\/p>\n<p><img class=\"alignnone size-full wp-image-7692\" src=\"https:\/\/matt.files.wordpress.com\/2016\/02\/img_5693-animation.gif?w=760&h=570\" alt=\"IMG_5693-ANIMATION.gif\" width=\"760\" height=\"570\" \/><\/p>\n<p><img class=\"alignnone size-full wp-image-7693\" src=\"https:\/\/matt.files.wordpress.com\/2016\/02\/img_5756-animation.gif?w=972&h=730\" alt=\"IMG_5756-ANIMATION.gif\" width=\"972\" height=\"730\" \/><\/p>\n<p><img class=\"alignnone size-full wp-image-7694\" src=\"https:\/\/matt.files.wordpress.com\/2016\/02\/img_5726-animation.gif?w=972&h=730\" alt=\"IMG_5726-ANIMATION.gif\" width=\"972\" height=\"730\" \/><\/p>\n<p><img class=\"alignnone size-full wp-image-7696\" src=\"https:\/\/matt.files.wordpress.com\/2016\/02\/img_5662-animation.gif?w=972&h=730\" alt=\"IMG_5662-ANIMATION.gif\" width=\"972\" height=\"730\" \/><\/p>\n",
                "excerpt": "<p>Thanks to some much-needed rain in California, the streams are running and I saw probably a dozen small waterfalls on a 7-mile hike on the Matt Davis trail, which starts near Stinson Beach. Here are four of them:<\/p>\n",
                "slug": "four-waterfalls-on-matt-davis-trail",
                "guid": "https:\/\/matt.wordpress.com\/?p=7689",
                "status": "publish",
                "sticky": false,
                "password": "",
                "parent": false,
                "type": "post",
                "comments_open": true,
                "pings_open": true,
                "likes_enabled": true,
                "sharing_enabled": true,
                "comment_count": 14,
                "like_count": 185,
                "i_like": 0,
                "is_reblogged": 0,
                "is_following": 0,
                "global_ID": "1c4e53754206dae4d7fa14b09a6801a0",
                "featured_image": "",
                "post_thumbnail": null,
                "format": "standard",
                "geo": false,
                "menu_order": 0,
                "publicize_URLs": [],
                "tags": {},
                "categories": {
                    "Moblog": {
                        "ID": 26114,
                        "name": "Moblog",
                        "slug": "moblog",
                        "description": "",
                        "post_count": 2253,
                        "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": {
                    "7696": {
                        "ID": 7696,
                        "URL": "https:\/\/matt.files.wordpress.com\/2016\/02\/img_5662-animation.gif",
                        "guid": "http:\/\/matt.files.wordpress.com\/2016\/02\/img_5662-animation.gif",
                        "mime_type": "image\/gif",
                        "width": 972,
                        "height": 730
                    },
                    "7694": {
                        "ID": 7694,
                        "URL": "https:\/\/matt.files.wordpress.com\/2016\/02\/img_5726-animation.gif",
                        "guid": "http:\/\/matt.files.wordpress.com\/2016\/02\/img_5726-animation.gif",
                        "mime_type": "image\/gif",
                        "width": 972,
                        "height": 730
                    },
                    "7693": {
                        "ID": 7693,
                        "URL": "https:\/\/matt.files.wordpress.com\/2016\/02\/img_5756-animation.gif",
                        "guid": "http:\/\/matt.files.wordpress.com\/2016\/02\/img_5756-animation.gif",
                        "mime_type": "image\/gif",
                        "width": 972,
                        "height": 730
                    },
                    "7692": {
                        "ID": 7692,
                        "URL": "https:\/\/matt.files.wordpress.com\/2016\/02\/img_5693-animation.gif",
                        "guid": "http:\/\/matt.files.wordpress.com\/2016\/02\/img_5693-animation.gif",
                        "mime_type": "image\/gif",
                        "width": 760,
                        "height": 570
                    }
                },
                "metadata": [
                    {
                        "id": "66229",
                        "key": "_wpas_done_2191330",
                        "value": "1"
                    },
                    {
                        "id": "66223",
                        "key": "_wpas_done_4543371",
                        "value": "1"
                    },
                    {
                        "id": "66226",
                        "key": "_wpas_done_4543378",
                        "value": "1"
                    },
                    {
                        "id": "66232",
                        "key": "_wpas_done_590",
                        "value": "1"
                    },
                    {
                        "id": "66220",
                        "key": "_wpas_done_591",
                        "value": "1"
                    },
                    {
                        "id": "66234",
                        "key": "_wpas_done_592",
                        "value": "1"
                    }
                ],
                "meta": {
                    "links": {
                        "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7689",
                        "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7689\/help",
                        "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4",
                        "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7689\/replies\/",
                        "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/7689\/likes\/"
                    }
                },
                "current_user_can": {
                    "publish_post": false,
                    "delete_post": false,
                    "edit_post": false
                },
                "capabilities": {
                    "publish_post": false,
                    "delete_post": false,
                    "edit_post": false
                }
            }
        ]
    }
}