If you’ve ever thought, “WordPress is just for blogs,” think again.
Thanks to the WordPress REST API, you can turn your WordPress site into a powerful backend for web and mobile applications. Whether you want to create a React-based front-end, build a mobile app with Flutter, or connect WordPress to third-party platforms, the REST API makes it possible.
In this guide, I’ll walk you through the basics of using the WordPress REST API — from fetching data to creating custom endpoints — and show you how it fits into app development in 2025.
So, What is the WordPress REST API?
The WordPress REST API lets you access your site’s content — like posts, pages, media, and users — using simple HTTP requests (like GET and POST).
Think of it as a bridge that lets your app “talk” to your WordPress site without needing to load any actual WordPress pages.
For example, you can fetch blog posts from your WordPress site and display them in a React app — no PHP required.
Common REST API Endpoints
WordPress gives you access to lots of data right out of the box. Here are a few of the most useful endpoints:
-
Posts:
/wp-json/wp/v2/posts
-
Pages:
/wp-json/wp/v2/pages
-
Users:
/wp-json/wp/v2/users
-
Categories:
/wp-json/wp/v2/categories
-
Media:
/wp-json/wp/v2/media
Try visiting one of these in your browser — you’ll see your content in JSON format.
Let’s Try a Simple Fetch Example (JavaScript)
Here’s how you could fetch posts using plain JavaScript:
<?php
fetch('https://yourdomain.com/wp-json/wp/v2/posts')
.then(res => res.json())
.then(posts => console.log(posts));
This is great for blog listings, news feeds, or even showing WordPress data inside an app dashboard.
Authentication: When You Need to Log In
Fetching public data (like posts) doesn’t need login. But if you want to create, update, or delete anything — like posting a new article — you’ll need to authenticate.
Here are two common ways:
1. Application Passwords (No Plugin Needed)
Available in WordPress 5.6+, this is the easiest way for basic authentication:
curl --user yourusername:your_app_password \
https://yourdomain.com/wp-json/wp/v2/posts
2. JWT Authentication (For More Control)
Install a plugin like JWT Authentication for WP REST API, get a token, and use it like this:
POST /wp-json/jwt-auth/v1/token
Then add this header in future requests:
Creating a New Post via API
Here’s how you could publish a new post from your app:
POST /wp-json/wp/v2/posts
Headers:
Authorization: Bearer YOUR_TOKEN
Body:
{
"title": "My First API Post",
"content": "This post was created using the WordPress REST API.",
"status": "publish"
}
Now imagine building an entire content app or dashboard with this power
Using the API in React or Flutter
Here’s a quick example using React with axios
:
import axios from 'axios';
axios.get('https://yourdomain.com/wp-json/wp/v2/posts')
.then(res => console.log(res.data));
Or, in Flutter using the http
package:
import 'package:http/http.dart' as http;
void fetchPosts() async {
final res = await http.get(Uri.parse('https://yourdomain.com/wp-json/wp/v2/posts'));
print(res.body);
}
These make it super easy to connect WordPress to your favorite frontend framework.
Want to Go Custom? Create Your Own Endpoints
You’re not limited to default endpoints — you can create your own.
Here’s a basic example you could add to your theme’s functions.php
file or a plugin:
<?php
add_action('rest_api_init', function () {
register_rest_route('custom/v1', '/hello', [
'methods' => 'GET',
'callback' => function () {
return ['message' => 'Hello from custom endpoint!'];
},
]);
});
Now you have an API endpoint at /wp-json/custom/v1/hello
. Cool, right?
Pro Tips for Working with the WordPress REST API
Here are a few best practices to keep in mind:
- Use authentication for any action that modifies data
- Use
?_embed
to get featured images with post data - Respect rate limits, especially for mobile apps
- Paginate your requests using
?page=1&per_page=10
Sanitize all user inputs when creating custom endpoints
Common Questions (FAQ)
❓Can I use the REST API to build a mobile app?
Absolutely! You can use it with Flutter, React Native, or any framework that supports HTTP requests.
❓Is the REST API secure?
Yes — as long as you use proper authentication and don’t expose sensitive data via public endpoints.
❓Do I need to install a plugin?
No, the core WordPress REST API is built-in. You only need plugins for advanced authentication (like JWT).
Final Thoughts
The WordPress REST API turns your website into a powerful data source that can fuel mobile apps, front-end frameworks like React and Vue, or even other WordPress sites. It’s a game-changer if you’re looking to build something beyond traditional themes.