GET /sites/$site/posts/slug:$post_slug

Get a single post (by slug).

Resource Information

   
Method GET
URL https://public-api.wordpress.com/rest/v1.1/sites/$site/posts/slug:$post_slug
Requires authentication? No

Method Parameters

Parameter Type Description
$site (int|string) Site ID or domain
$post_slug (string) The post slug (a.k.a. sanitized name)

Query Parameters

Parameter Type Description
context (string)
display:
(default) Formats the output as HTML for display. Shortcodes are parsed, paragraph tags are added, etc..
edit:
Formats the output for editing. Shortcodes are left unparsed, significant whitespace is kept, etc..
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.

Response Parameters

Parameter Type Description
ID (int) The post ID.
site_ID (int) The site ID.
author (object) The author of the post.
date (iso 8601 datetime) The post's creation time.
modified (iso 8601 datetime) The post's most recent update time.
title (html) context dependent.
URL (url) The full permalink URL to the post.
short_URL (url) The wp.me short URL.
content (html) context dependent.
excerpt (html) context dependent.
slug (string) The name (slug) for the post, used in URLs.
guid (string) The GUID for the post.
status (string)
publish:
The post is published.
draft:
The post is saved as a draft.
pending:
The post is pending editorial approval.
private:
The post is published privately
future:
The post is scheduled for future publishing.
trash:
The post is in the trash.
auto-draft:
The post is a placeholder for a new post.
sticky (bool) Is the post sticky?
password (string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.
parent (object|false) A reference to the post's parent, if it has one.
type (string) The post's post_type. Post types besides post, page and revision need to be whitelisted using the rest_api_allowed_post_types filter.
discussion (object) Hash of discussion options for the post
likes_enabled (bool) Is the post open to likes?
sharing_enabled (bool) Should sharing buttons show on this post?
like_count (int) The number of likes for this post.
i_like (bool) Does the current user like this post?
is_reblogged (bool) Did the current user reblog this post?
is_following (bool) Is the current user following this blog?
global_ID (string) A unique WordPress.com-wide representation of a post.
featured_image (url) The URL to the featured image for this post if it has one.
post_thumbnail (object) The attachment object for the featured image if it has one.
format (string)
standard:
Standard
aside:
Aside
chat:
Chat
gallery:
Gallery
link:
Link
image:
Image
quote:
Quote
status:
Status
video:
Video
audio:
Audio
geo (object|false)
menu_order (int) (Pages Only) The order pages should appear in.
page_template (string) (Pages Only) The page template this page is using.
publicize_URLs (array) Array of Twitter and Facebook URLs published by this post.
terms (object) Hash of taxonomy names mapping to a hash of terms keyed by term name.
tags (object) Hash of tags (keyed by tag name) applied to the post.
categories (object) Hash of categories (keyed by category name) applied to the post.
attachments (object) Hash of post attachments (keyed by attachment ID). Returns the most recent 20 attachments. Use the `/sites/$site/media` endpoint to query the attachments beyond the default of 20 that are returned here.
attachment_count (int) The total number of attachments for this post. Use the `/sites/$site/media` endpoint to query the attachments beyond the default of 20 that are returned here.
metadata (array) Array of post metadata keys and values. All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are available for authenticated requests with access. Protected meta keys can be made available with the rest_api_allowed_public_metadata filter.
meta (object) API result meta data
capabilities (object) List of post-specific permissions for the user; publish_post, edit_post, delete_post
revisions (array) List of post revision IDs. Only available for posts retrieved with context=edit.
other_URLs (object) List of URLs for this post. Permalink and slug suggestions.

Resource Errors

These are the possible errors returned by this endpoint.

HTTP Code Error Identifier Error Message
400 invalid_field Invalid API FIELD
403 unauthorized User cannot access this private blog.
403 unauthorized User cannot access this restricted blog
400 invalid_context Invalid API CONTEXT
404 unknown_post Unknown post

Example

curl 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/slug:blogging-and-stuff'
<?php
$options  = array (
  'http' => 
  array (
    'ignore_errors' => true,
  ),
);

$context  = stream_context_create( $options );
$response = file_get_contents(
	'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/slug:blogging-and-stuff',
	false,
	$context
);
$response = json_decode( $response );
?>

Response

{
    "ID": 7,
    "site_ID": 3584907,
    "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",
        "profile_URL": "https:\/\/en.gravatar.com\/matt",
        "site_ID": 4
    },
    "date": "2005-09-26T21:43:58+00:00",
    "modified": "2005-09-26T21:43:58+00:00",
    "title": "So should we be, like, blogging and stuff too?",
    "URL": "http:\/\/en.blog.wordpress.com\/2005\/09\/26\/blogging-and-stuff\/",
    "short_URL": "https:\/\/wp.me\/pf2B5-7",
    "content": "<p>It is absolutely is criminal we don’t have an official blog for WordPress.com yet. It was all just a ploy to get you to read my, Donncha, Andy, and Ryan’s blogs. But now that the secret is out, we should start blogging officially, and this is as good a place as any. We’re adding new features nearly every day, so at least we’ll have something to write about. <\/p>\n",
    "excerpt": "<p>It is absolutely is criminal we don’t have an official blog for WordPress.com yet. It was all just a ploy to get you to read my, Donncha, Andy, and Ryan’s blogs. But now that the secret is out, we should start blogging officially, and this is as good a place as any. We’re adding new [&hellip;]<\/p>\n",
    "slug": "blogging-and-stuff",
    "guid": "http:\/\/wordpress.com\/2005\/09\/26\/blogging-and-stuff\/",
    "status": "publish",
    "sticky": false,
    "password": "",
    "parent": false,
    "type": "post",
    "discussion": {
        "comments_open": false,
        "comment_status": "open",
        "pings_open": false,
        "ping_status": "open",
        "comment_count": 8
    },
    "likes_enabled": true,
    "sharing_enabled": true,
    "like_count": 10,
    "i_like": false,
    "is_reblogged": false,
    "is_following": false,
    "global_ID": "3e1080a3f47c8e54dee7ae98e94b1796",
    "featured_image": "",
    "post_thumbnail": null,
    "format": "standard",
    "geo": false,
    "menu_order": 0,
    "page_template": "",
    "publicize_URLs": [],
    "terms": {
        "category": {},
        "post_tag": {
            "Introduction": {
                "ID": 885,
                "name": "Introduction",
                "slug": "introduction",
                "description": "",
                "post_count": 2,
                "meta": {
                    "links": {
                        "self": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/3584907\/tags\/slug:introduction",
                        "help": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/3584907\/tags\/slug:introduction\/help",
                        "site": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/3584907"
                    }
                }
            }
        },
        "post_format": {},
        "mentions": {}
    },
    "tags": {
        "Introduction": {
            "ID": 885,
            "name": "Introduction",
            "slug": "introduction",
            "description": "",
            "post_count": 2,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/3584907\/tags\/slug:introduction",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/3584907\/tags\/slug:introduction\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/3584907"
                }
            }
        }
    },
    "categories": {},
    "attachments": {},
    "attachment_count": 0,
    "metadata": [],
    "meta": {
        "links": {
            "self": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/3584907\/posts\/7",
            "help": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/3584907\/posts\/7\/help",
            "site": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/3584907",
            "replies": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/3584907\/posts\/7\/replies\/",
            "likes": "https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/3584907\/posts\/7\/likes\/"
        }
    },
    "capabilities": {
        "publish_post": false,
        "delete_post": false,
        "edit_post": false
    },
    "other_URLs": {}
}