WordPress REST API

WordPress REST API Reference

Quick reference for accessing WordPress content via the REST API.

Base URL

https://your-site.com/wp-json/wp/v2/{endpoint}

Endpoints

Endpoint Description
/wp-json/wp/v2/types All registered post types (including CPTs)
/wp-json/wp/v2/taxonomies All registered taxonomies
/wp-json/wp/v2/posts Blog posts
/wp-json/wp/v2/posts/{id} Single post by ID
/wp-json/wp/v2/pages Pages
/wp-json/wp/v2/pages/{id} Single page by ID
/wp-json/wp/v2/media All media attachments
/wp-json/wp/v2/media/{id} Single media item
/wp-json/wp/v2/categories Categories
/wp-json/wp/v2/tags Tags
/wp-json/wp/v2/users Users (public info)
/wp-json/wp/v2/comments Comments

Query Parameters

Pagination

/wp-json/wp/v2/posts?per_page=100&page=1
  • per_page - Items per request (default: 10, max: 100)
  • page - Page number (starts at 1)
  • offset - Skip a number of items

Response Headers:

  • X-WP-Total - Total number of items
  • X-WP-TotalPages - Total number of pages

Filtering

/wp-json/wp/v2/posts?categories=5&tags=10,15
Parameter Description Example
search Search term ?search=hello
author Author ID(s) ?author=1,2
categories Category ID(s) ?categories=3,5
tags Tag ID(s) ?tags=10
slug Post slug ?slug=my-post
before Posts before date ?before=2024-01-01T00:00:00
after Posts after date ?after=2023-01-01T00:00:00
include Specific IDs only ?include=1,5,10
exclude Exclude specific IDs ?exclude=2,3

Ordering

/wp-json/wp/v2/posts?orderby=date&order=asc
  • orderby - date, id, title, slug, modified, author, relevance (search only)
  • order - asc or desc

Field Selection

/wp-json/wp/v2/posts?_fields=id,title,link

Reduce response size by selecting only needed fields.

Embedding Related Data

/wp-json/wp/v2/posts?_embed

Includes author, featured media, and term data in response.

Sources