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, mostly photos",
        "description": "Stuff and things.",
        "URL": "http:\/\/matt.blog",
        "jetpack": false,
        "jetpack_connection": false,
        "subscribers_count": 237028,
        "lang": false,
        "icon": {
            "img": "https:\/\/secure.gravatar.com\/blavatar\/eef825a9efa93dc9e544af3e746294808fb6d1fb97a3e357dfbab433bda59e38",
            "ico": "https:\/\/secure.gravatar.com\/blavatar\/eef825a9efa93dc9e544af3e746294808fb6d1fb97a3e357dfbab433bda59e38"
        },
        "logo": {
            "id": 0,
            "sizes": [],
            "url": ""
        },
        "visible": null,
        "is_private": false,
        "is_coming_soon": false,
        "is_following": false,
        "organization_id": 0,
        "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"
            }
        },
        "launch_status": false,
        "site_migration": null,
        "is_fse_active": false,
        "is_fse_eligible": false,
        "is_core_site_editor_enabled": false,
        "is_wpcom_atomic": false,
        "is_wpcom_staging_site": false
    },
    "\/sites\/4\/posts?number=1": {
        "found": 2387,
        "posts": [
            {
                "ID": 8641,
                "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:\/\/0.gravatar.com\/avatar\/33252cd1f33526af53580fcb1736172f06e6716f32afdd1be19ec3096d15dea5?s=96&d=retro&r=G",
                    "profile_URL": "https:\/\/en.gravatar.com\/matt",
                    "ip_address": false,
                    "site_ID": 4,
                    "site_visible": true
                },
                "date": "2023-09-06T05:01:39+00:00",
                "modified": "2023-09-06T05:01:39+00:00",
                "title": "Dark Bay Bridge",
                "URL": "http:\/\/matt.blog\/2023\/09\/06\/dark-bay-bridge\/",
                "short_URL": "https:\/\/wp.me\/p4-2fn",
                "content": "\n<figure class=\"wp-block-image size-large\"><img data-attachment-id=\"8640\" data-permalink=\"http:\/\/matt.blog\/2023\/09\/06\/dark-bay-bridge\/img_0714\/\" data-orig-file=\"https:\/\/matt.files.wordpress.com\/2023\/09\/img_0714.jpg\" data-orig-size=\"4032,3024\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;1.78&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;iPhone 14 Pro&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1693778249&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;6.86&quot;,&quot;iso&quot;:&quot;3200&quot;,&quot;shutter_speed&quot;:&quot;0.2&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}\" data-image-title=\"img_0714\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/matt.files.wordpress.com\/2023\/09\/img_0714.jpg?w=300\" data-large-file=\"https:\/\/matt.files.wordpress.com\/2023\/09\/img_0714.jpg?w=1024\" src=\"https:\/\/matt.files.wordpress.com\/2023\/09\/img_0714.jpg?w=1024\" class=\"wp-image-8640\" srcset=\"https:\/\/matt.files.wordpress.com\/2023\/09\/img_0714.jpg?w=1024 1024w, https:\/\/matt.files.wordpress.com\/2023\/09\/img_0714.jpg?w=2048 2048w, https:\/\/matt.files.wordpress.com\/2023\/09\/img_0714.jpg?w=150 150w, https:\/\/matt.files.wordpress.com\/2023\/09\/img_0714.jpg?w=300 300w, https:\/\/matt.files.wordpress.com\/2023\/09\/img_0714.jpg?w=768 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>It was so sad seeing the Bay Bridge so dark the other night even some of the normal lights weren\u2019t working. We need to get the Bay Lights back! <a href=\"https:\/\/crowdfundr.com\/TheBayLights360\">Please donate.<\/a><\/p>\n",
                "excerpt": "<p>It was so sad seeing the Bay Bridge so dark the other night even some of the normal lights weren\u2019t working. We need to get the Bay Lights back! Please donate.<\/p>\n",
                "slug": "dark-bay-bridge",
                "guid": "http:\/\/matt.blog\/2023\/09\/06\/dark-bay-bridge\/",
                "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": 35,
                "i_like": false,
                "is_reblogged": false,
                "is_following": false,
                "global_ID": "91675a4752f1c4dc082f676dd90f4b71",
                "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": 2332,
                        "feed_url": "http:\/\/matt.blog\/category\/moblog\/feed\/",
                        "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": {
                    "8640": {
                        "ID": 8640,
                        "URL": "https:\/\/matt.files.wordpress.com\/2023\/09\/img_0714.jpg",
                        "guid": "http:\/\/matt.files.wordpress.com\/2023\/09\/img_0714.jpg",
                        "mime_type": "image\/jpeg",
                        "width": 4032,
                        "height": 3024
                    }
                },
                "metadata": false,
                "meta": {
                    "links": {
                        "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/8641",
                        "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/8641\/help",
                        "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4",
                        "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/8641\/replies\/",
                        "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/4\/posts\/8641\/likes\/"
                    }
                },
                "current_user_can": {
                    "publish_post": false,
                    "delete_post": false,
                    "edit_post": false
                },
                "capabilities": {
                    "publish_post": false,
                    "delete_post": false,
                    "edit_post": false
                }
            }
        ]
    }
}