Skip to content
WilliamAlexander.co
  • Studio
  • Work
  • Services
  • Process
  • Writing
  • Lab
  • About
  • Start a project
  1. Home
  2. Articles
  3. WordPress REST API for Beginners
WordPress Enterprise

WordPress REST API for Beginners

Understanding WordPress as a data platform

June 20, 2026 11 min read

Key Takeaways

  • The REST API exposes WordPress content as data endpoints
  • Public content is accessible; private content requires authentication
  • Standard HTTP methods: GET (read), POST (create), PUT (update), DELETE (remove)
  • Custom endpoints extend the API for specific needs
  • Opens possibilities for mobile apps, headless sites, and integrations
Overview

What Is the REST API?

Traditionally, WordPress generates HTML pages when visitors request URLs. The REST API adds another layer: it provides WordPress data in a structured format (JSON) that other applications can understand. Instead of "give me the blog page," you can say "give me the post data for post ID 42."

This transforms WordPress from a website builder into a content platform. Your WordPress content can power mobile apps, custom front-ends, external dashboards, automated workflows, and integrations with other systems—all while you manage content in the familiar WordPress admin.

WordPress as a Content Hub

The REST API separates content management from content display. WordPress handles content creation and storage. Other systems can consume that content and display it however they want. This is the foundation of "headless" WordPress.

Basics

REST API Basics

What REST Means

REST (Representational State Transfer) is an architecture style for web services. Key concepts:

  • Resources: Things you can access (posts, users, pages)
  • Endpoints: URLs that represent resources
  • Methods: Actions you can perform (GET, POST, PUT, DELETE)
  • JSON: Data format for requests and responses

HTTP Methods

Method Action Example
GET Read data Retrieve a post
POST Create new data Create a new post
PUT/PATCH Update existing data Edit a post
DELETE Remove data Delete a post

WordPress API Structure

The WordPress REST API follows a consistent URL pattern:

  • yoursite.com/wp-json/ — API root
  • yoursite.com/wp-json/wp/v2/ — WordPress core namespace
  • yoursite.com/wp-json/wp/v2/posts — Posts endpoint
  • yoursite.com/wp-json/wp/v2/posts/123 — Specific post
Endpoints

Default Endpoints

WordPress provides endpoints for all core content types.

Content Endpoints

  • /wp/v2/posts — Blog posts
  • /wp/v2/pages — Pages
  • /wp/v2/media — Media library items
  • /wp/v2/comments — Comments

Taxonomy Endpoints

  • /wp/v2/categories — Categories
  • /wp/v2/tags — Tags

User Endpoints

  • /wp/v2/users — Users (public info only by default)
  • /wp/v2/users/me — Current authenticated user

Settings and System

  • /wp/v2/settings — Site settings (authenticated)
  • /wp/v2/types — Registered post types
  • /wp/v2/statuses — Post statuses

Discover Available Endpoints

Visit yoursite.com/wp-json/ to see all available endpoints and their routes. This self-describing nature makes the API easier to explore and understand.
Requests

Making Requests

Using Your Browser

The simplest way to explore: just visit the URL. Open yoursite.com/wp-json/wp/v2/posts in your browser to see JSON data for your posts.

Using Command Line

# Get all posts
curl https://yoursite.com/wp-json/wp/v2/posts

# Get a specific post
curl https://yoursite.com/wp-json/wp/v2/posts/123

# Get posts with specific parameters
curl "https://yoursite.com/wp-json/wp/v2/posts?per_page=5&categories=10"

Common Parameters

  • per_page — Number of results (max 100)
  • page — Page number for pagination
  • search — Search term
  • categories — Filter by category ID
  • tags — Filter by tag ID
  • orderby — Sort field (date, title, etc.)
  • order — Sort direction (asc, desc)

Understanding Responses

API responses include:

  • Response body: The JSON data you requested
  • Headers: Metadata including pagination info
  • Status codes: Success (200), created (201), error (4xx, 5xx)
Authentication

Authentication

Public content is accessible without authentication. Creating, editing, or deleting content requires authentication.

Authentication Methods

  • Cookie authentication: For logged-in WordPress users (includes nonce)
  • Application passwords: Built into WordPress 5.6+ for external apps
  • OAuth: For third-party integrations (requires plugin)
  • JWT tokens: Popular for headless setups (requires plugin)

Application Passwords

The simplest method for external applications:

  1. Go to Users → Your Profile

    Scroll to Application Passwords section.

  2. Create new application password

    Give it a descriptive name for the application using it.

  3. Save the password

    Copy it immediately—it won't be shown again.

  4. Use with Basic Auth

    Include username and application password in requests.

# Authenticated request with application password
curl --user "username:application_password" \
  https://yoursite.com/wp-json/wp/v2/posts

Security Considerations

Application passwords grant access to your account. Create separate passwords for each application so you can revoke access individually. Never share passwords in public repositories or client-side code.
Writing

Creating and Updating Content

Creating a Post

curl --user "username:app_password" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "title": "My New Post",
    "content": "This is the post content.",
    "status": "publish"
  }' \
  https://yoursite.com/wp-json/wp/v2/posts

Updating a Post

curl --user "username:app_password" \
  -X PUT \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Updated Title"
  }' \
  https://yoursite.com/wp-json/wp/v2/posts/123

Deleting a Post

# Move to trash
curl --user "username:app_password" \
  -X DELETE \
  https://yoursite.com/wp-json/wp/v2/posts/123

# Permanently delete
curl --user "username:app_password" \
  -X DELETE \
  https://yoursite.com/wp-json/wp/v2/posts/123?force=true
Use Cases

Practical Use Cases

Mobile Applications

Build iOS or Android apps that read and write WordPress content. Your team manages content in WordPress; users access it through native apps.

Headless WordPress

Use WordPress for content management, but display content through a custom front-end built with React, Vue, or other frameworks.

Integrations

  • Sync content to external systems
  • Trigger workflows when content changes
  • Import content from other platforms
  • Connect with marketing automation tools

Custom Dashboards

Build specialized interfaces that pull WordPress data but display it differently than the admin area—executive dashboards, editorial workflows, client portals.

Static Site Generation

Use the API to pull content at build time for static site generators like Gatsby or Next.js. WordPress handles content; the static site provides speed and security.

Content Syndication

Publish once in WordPress, distribute everywhere. The API makes it easy to push content to multiple channels—social media, email platforms, partner sites—automatically.

Custom

Custom Endpoints

When built-in endpoints don't meet your needs, create custom ones.

Registering Custom Endpoints

add_action( 'rest_api_init', function() {
    register_rest_route( 'myplugin/v1', '/featured-content', array(
        'methods'  => 'GET',
        'callback' => 'get_featured_content',
        'permission_callback' => '__return_true',
    ));
});

function get_featured_content( $request ) {
    // Your logic to fetch featured content
    $data = array(
        'title' => 'Featured Item',
        'url'   => 'https://example.com',
    );
    return new WP_REST_Response( $data, 200 );
}

When to Create Custom Endpoints

  • Combining data from multiple sources
  • Complex queries not possible with default endpoints
  • Exposing custom post type data
  • Creating simplified responses for specific apps
Conclusion

Getting Started

The REST API opens WordPress to possibilities beyond traditional websites. You don't need to use it for everything—sometimes a standard WordPress site is exactly right. But understanding the API prepares you for projects that need more flexibility.

Start by exploring the API on your own site. Visit /wp-json/ and browse the endpoints. Try fetching posts with different parameters. Experiment with tools like Postman. The API is already there, waiting to be used.

Frequently Asked Questions

Is the REST API enabled by default in WordPress?

Yes, the REST API is built into WordPress core since version 4.7. It works out of the box with no additional plugins required. You can immediately access content endpoints like /wp-json/wp/v2/posts on any WordPress site.

Is the WordPress REST API secure?

The API is secure by default—sensitive operations require authentication. Public endpoints only expose content that's already public on your site. However, you should review what's exposed if security is a concern, and consider plugins that limit or disable API access for sensitive sites.

Can I use the REST API without knowing how to code?

Understanding REST API concepts is valuable even without coding. Tools like Postman let you explore APIs visually. Zapier and similar platforms can connect to REST APIs without code. However, building custom integrations does require development skills.

What's the difference between REST API and GraphQL for WordPress?

REST API is built into WordPress core and uses standard HTTP endpoints. GraphQL (via plugins like WPGraphQL) lets you request exactly the data you need in a single query. GraphQL is more flexible but adds complexity. REST API is simpler and sufficient for most needs.
WordPress API Development Technical Integration
William Alexander

William Alexander

Senior Web Developer

25+ years of web development experience spanning higher education and small business. Currently Senior Web Developer at Wake Forest University.

Related Articles

WordPress Enterprise

WordPress Plugin Conflicts: Prevention and Resolution

12 min read
WordPress Enterprise

WordPress Staging Environments: A Complete Guide

12 min read

Need help with WordPress API development?

I help organizations build custom WordPress integrations and headless solutions. Let's discuss your technical requirements.

Let's talk about your project.

Send a few sentences about what you're working on. Start a project →

Practice

  • Work
  • Services
  • Web design
  • Process
  • Start a project

Read & explore

  • Writing
  • Lab
  • About
  • Resume

Elsewhere

  • LinkedIn
  • GitHub
  • Email

Based

Roanoke, Virginia
Working in Eastern Time

Selectively available, Q3 2026

© 2026 William Alexander. Built by hand in Roanoke, Virginia.

Set in Inter and Fraunces. Running on WordPress, hosted on Flywheel.