GET /read/tags/$tag/posts

Get a list of posts from a tag.

Resource Information

   
Method GET
URL https://public-api.wordpress.com/rest/v1.1/read/tags/$tag/posts
Requires authentication? No

Method Parameters

Parameter Type Description
$tag (string) The tag name

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.
number (int) The number of posts to return. Limit: 40. Default: 10.
page (int) Return the Nth 1-indexed page of posts.
order (string)
DESC:
(default) Return posts in descending order. For dates, that means newest to oldest.
ASC:
Return posts in ascending order. For dates, that means oldest to newest.
after (iso 8601 datetime) Return posts dated after the specified datetime.
before (iso 8601 datetime) Return posts dated before the specified datetime.

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.
comments_open (bool) Is the post open for comments?
pings_open (bool) Is the post open for pingbacks, trackbacks?
likes_enabled (bool) Is the post open to likes?
sharing_enabled (bool) Should sharing buttons show on this post?
comment_count (int) The number of comments for 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.
publicize_URLs (array) Array of Twitter and Facebook URLs published by this post.
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).
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
current_user_can (object) List of permissions. Note, deprecated in favor of `capabilities`
capabilities (object) List of post-specific permissions for the user; publish_post, edit_post, delete_post
date_range (object) date range covered by current results.
number (int) The number of posts brought back by current query.
posts (array) An array of post objects.

Resource Errors

These are the possible errors returned by this endpoint.

HTTP Code Error Identifier Error Message
400 invalid_tag The tag requested does not seem to be valid.
403 unauthorized User cannot view taxonomy
403 unauthorized User cannot view post
400 invalid_topic The TOPIC parameter must be specified.
403 unauthorized User cannot edit taxonomy
400 invalid_post Invalid post
400 invalid_context Invalid API CONTEXT
403 unauthorized User cannot edit post
404 unknown_post Unknown post

Example

curl 'https://public-api.wordpress.com/rest/v1/read/tags/wordpress/posts/?number=2'
<?php
$options  = array (
  'http' => 
  array (
    'ignore_errors' => true,
  ),
);

$context  = stream_context_create( $options );
$response = file_get_contents(
	'https://public-api.wordpress.com/rest/v1/read/tags/wordpress/posts/?number=2',
	false,
	$context
);
$response = json_decode( $response );
?>

Response

{
    "date_range": {
        "before": "2018-04-24T22:58:19-07:00",
        "after": "2018-04-25T07:55:36+02:00"
    },
    "number": 2,
    "posts": [
        {
            "ID": 5864,
            "site_ID": 122507670,
            "author": {
                "ID": 115538571,
                "login": "teresacreationsblog",
                "email": false,
                "name": "teresacreationsblog",
                "first_name": "Teresa",
                "last_name": "Creation's",
                "nice_name": "teresacreationsblog",
                "URL": "http:\/\/teresacreationsblog.wordpress.com",
                "avatar_URL": "https:\/\/1.gravatar.com\/avatar\/7a5d57376488173fc1557615b00ce53b?s=96&d=identicon&r=G",
                "profile_URL": "https:\/\/en.gravatar.com\/teresacreationsblog",
                "ip_address": false,
                "site_ID": 122507670,
                "site_visible": true
            },
            "date": "2018-04-24T22:58:19-07:00",
            "modified": "2018-04-24T22:58:19-07:00",
            "title": "Mother Teresa’s ‘The Joy In Loving’ April 25",
            "URL": "https:\/\/teresacreationsblog.wordpress.com\/2018\/04\/24\/mother-teresas-the-joy-in-loving-april-25\/",
            "short_URL": "https:\/\/wp.me\/p8i1Qa-1wA",
            "content": "<p><i>‘You will find Calcutta all over the world if you have eyes to see. The streets of Calcutta lead to every man\u2019s door. I know that you may want to make a trip to Calcutta , but it is easy to love people far away. It is not always easy to love those people who live beside us. What about the ones I dislike or look down upon?<\/i><\/p>\n",
            "excerpt": "<p>‘You will find Calcutta all over the world if you have eyes to see. The streets of Calcutta lead to every man\u2019s door. I know that you may want to make a trip to Calcutta , but it is easy to love people far away. It is not always easy to love those people who [&hellip;]<\/p>\n",
            "slug": "mother-teresas-the-joy-in-loving-april-25",
            "guid": "https:\/\/teresacreationsblog.wordpress.com\/?p=5864",
            "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": 1,
            "i_like": false,
            "is_reblogged": false,
            "is_following": false,
            "global_ID": "5252fd1d33a46be5ac42925f9dd8d5b5",
            "featured_image": "",
            "post_thumbnail": null,
            "format": "standard",
            "geo": false,
            "menu_order": 0,
            "publicize_URLs": [],
            "tags": {
                "Blog": {
                    "ID": 273,
                    "name": "Blog",
                    "slug": "blog",
                    "description": "",
                    "post_count": 419,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:blog",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:blog\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670"
                        }
                    }
                },
                "Blogging": {
                    "ID": 91,
                    "name": "Blogging",
                    "slug": "blogging",
                    "description": "",
                    "post_count": 789,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:blogging",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:blogging\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670"
                        }
                    }
                },
                "Faith": {
                    "ID": 401,
                    "name": "Faith",
                    "slug": "faith",
                    "description": "",
                    "post_count": 104,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:faith",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:faith\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670"
                        }
                    }
                },
                "Life": {
                    "ID": 124,
                    "name": "Life",
                    "slug": "life",
                    "description": "",
                    "post_count": 680,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:life",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:life\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670"
                        }
                    }
                },
                "Mother Teresa": {
                    "ID": 196820,
                    "name": "Mother Teresa",
                    "slug": "mother-teresa",
                    "description": "",
                    "post_count": 108,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:mother-teresa",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:mother-teresa\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670"
                        }
                    }
                },
                "Prayer": {
                    "ID": 853,
                    "name": "Prayer",
                    "slug": "prayer",
                    "description": "",
                    "post_count": 123,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:prayer",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:prayer\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670"
                        }
                    }
                },
                "Religion": {
                    "ID": 116,
                    "name": "Religion",
                    "slug": "religion",
                    "description": "",
                    "post_count": 470,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:religion",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:religion\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670"
                        }
                    }
                },
                "WordPress": {
                    "ID": 33,
                    "name": "WordPress",
                    "slug": "wordpress",
                    "description": "",
                    "post_count": 789,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:wordpress",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:wordpress\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670"
                        }
                    }
                },
                "Writing": {
                    "ID": 349,
                    "name": "Writing",
                    "slug": "writing",
                    "description": "",
                    "post_count": 779,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:writing",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/tags\/slug:writing\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670"
                        }
                    }
                }
            },
            "categories": {
                "The Joy in Loving": {
                    "ID": 98356873,
                    "name": "The Joy in Loving",
                    "slug": "the-joy-in-loving",
                    "description": "",
                    "post_count": 113,
                    "parent": 0,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/categories\/slug:the-joy-in-loving",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/categories\/slug:the-joy-in-loving\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670"
                        }
                    }
                }
            },
            "attachments": {},
            "metadata": [
                {
                    "id": "17680",
                    "key": "_wpas_done_16907333",
                    "value": "1"
                },
                {
                    "id": "17684",
                    "key": "_wpas_done_16907335",
                    "value": "1"
                }
            ],
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/posts\/5864",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/posts\/5864\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/posts\/5864\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/122507670\/posts\/5864\/likes\/"
                }
            },
            "current_user_can": {
                "publish_post": false,
                "delete_post": false,
                "edit_post": false
            },
            "capabilities": {
                "publish_post": false,
                "delete_post": false,
                "edit_post": false
            },
            "pseudo_ID": "5252fd1d33a46be5ac42925f9dd8d5b5",
            "is_external": false,
            "site_name": "Teresa Creation's",
            "site_URL": "https:\/\/teresacreationsblog.wordpress.com",
            "site_is_private": false,
            "featured_media": {}
        },
        {
            "ID": 252,
            "site_ID": 143420196,
            "author": {
                "ID": 121571358,
                "login": "stenolmre41",
                "email": false,
                "name": "stenolmre",
                "first_name": "Sten",
                "last_name": "Olmre",
                "nice_name": "stenolmre41",
                "URL": "http:\/\/stenolmre.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/c991a3d6e3386ccb399179177b50476e?s=96&d=identicon&r=G",
                "profile_URL": "https:\/\/en.gravatar.com\/stenolmre41",
                "ip_address": false,
                "site_ID": 143420196,
                "site_visible": true
            },
            "date": "2018-04-25T07:55:36+02:00",
            "modified": "2018-04-25T07:55:36+02:00",
            "title": "The Moment",
            "URL": "http:\/\/labakinnas.com\/2018\/04\/25\/the-moment\/",
            "short_URL": "https:\/\/wp.me\/p9HM8Y-44",
            "content": "<p>the moment<\/p>\n<p>i realiezed i’m in love<\/p>\n<p>was when you were in the middle of the crowd<\/p>\n<p>and it didn’t take a second to find you<\/p>\n",
            "excerpt": "<p>the moment i realiezed i’m in love was when you were in the middle of the crowd and it didn’t take a second to find you<\/p>\n",
            "slug": "the-moment",
            "guid": "http:\/\/labakinnas.com\/?p=252",
            "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": 0,
            "i_like": false,
            "is_reblogged": false,
            "is_following": false,
            "global_ID": "30781737a8fc4966dde63f9f1248090f",
            "featured_image": "",
            "post_thumbnail": null,
            "format": "standard",
            "geo": {
                "latitude": 33.894667,
                "longitude": -118.224289,
                "address": ""
            },
            "menu_order": 0,
            "publicize_URLs": [],
            "tags": {
                "inspiration": {
                    "ID": 107,
                    "name": "inspiration",
                    "slug": "inspiration",
                    "description": "",
                    "post_count": 7,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/tags\/slug:inspiration",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/tags\/slug:inspiration\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196"
                        }
                    }
                },
                "love": {
                    "ID": 3785,
                    "name": "love",
                    "slug": "love",
                    "description": "",
                    "post_count": 7,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/tags\/slug:love",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/tags\/slug:love\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196"
                        }
                    }
                },
                "Poetry": {
                    "ID": 422,
                    "name": "Poetry",
                    "slug": "poetry",
                    "description": "",
                    "post_count": 6,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/tags\/slug:poetry",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/tags\/slug:poetry\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196"
                        }
                    }
                },
                "random": {
                    "ID": 30,
                    "name": "random",
                    "slug": "random",
                    "description": "",
                    "post_count": 3,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/tags\/slug:random",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/tags\/slug:random\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196"
                        }
                    }
                },
                "wordpress": {
                    "ID": 33,
                    "name": "wordpress",
                    "slug": "wordpress",
                    "description": "",
                    "post_count": 7,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/tags\/slug:wordpress",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/tags\/slug:wordpress\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196"
                        }
                    }
                }
            },
            "categories": {
                "Poetry": {
                    "ID": 422,
                    "name": "Poetry",
                    "slug": "poetry",
                    "description": "Controlled loneliness.",
                    "post_count": 9,
                    "parent": 0,
                    "meta": {
                        "links": {
                            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/categories\/slug:poetry",
                            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/categories\/slug:poetry\/help",
                            "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196"
                        }
                    }
                }
            },
            "attachments": {},
            "metadata": [
                {
                    "id": "844",
                    "key": "geo_latitude",
                    "value": "33.8946672"
                },
                {
                    "id": "845",
                    "key": "geo_longitude",
                    "value": "-118.2242893"
                },
                {
                    "id": "846",
                    "key": "geo_public",
                    "value": "1"
                }
            ],
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/posts\/252",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/posts\/252\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/posts\/252\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/143420196\/posts\/252\/likes\/"
                }
            },
            "current_user_can": {
                "publish_post": false,
                "delete_post": false,
                "edit_post": false
            },
            "capabilities": {
                "publish_post": false,
                "delete_post": false,
                "edit_post": false
            },
            "pseudo_ID": "30781737a8fc4966dde63f9f1248090f",
            "is_external": false,
            "site_name": "Labakinnas",
            "site_URL": "http:\/\/labakinnas.com",
            "site_is_private": false,
            "featured_media": {}
        }
    ]
}