Questions tagged [wordpress-rest-api]

The WordPress REST API

WordPress' REST API provides a variety of endpoints for interacting with data that is stored within a WordPress' site database. Since version 4.4, it's now possible to remotely manage this data which is provided in a JSON (JavaScript Object Notation) format, ideal for extending the functionality for bespoke application usage.

1592 questions
96
votes
22 answers

Wordpress REST API (wp-api) 404 Error: Cannot access the WordPress REST API

I have been using the Wordpress REST plugin WP-API for months now while developing locally with XAMPP. I recently migrated my site to an EC2 instance and everything is working fine except I now get a 404 with the following message whenever I try to…
dsal1951
  • 1,630
  • 1
  • 16
  • 20
38
votes
15 answers

WooCommerce - woocommerce_rest_cannot_view - Status 401

I have generated a consumer key and consumer secret. The website has SSL installed. I have also installed plugins required for JSON and REST services. This is how the url looks like: https:///wp-json/wc/v1/products When I am trying to get(GET)…
25
votes
3 answers

WordPress REST API Custom Endpoint with URL Parameter

I am trying to create a custom endpoint for the WordPress REST API and pass parameters through the URL. The endpoint currently is: /wp-json/v1/products/81838240219 What I am trying to achieve is an endpoint that looks like this and being able to…
Rob Gelhausen
  • 475
  • 1
  • 5
  • 9
22
votes
7 answers

WP Rest API upload image

I'm trying to upload image via Wordpress REST api v2. So far all I managed was to create empty entries in wordpress media library. Meaning they have image names, but no actual image. POST…
CrazySabbath
  • 1,274
  • 3
  • 11
  • 33
20
votes
4 answers

How to expose all the ACF fields to Wordpress REST API in both pages and custom postypes

I want to expose all the ACF fields that belong to a page or custom post type to the WordPress REST API in order to do some API calls through javascript. The final expected result would be all the ACF fields inside an ACF object that you can easily…
Mel Macaluso
  • 3,250
  • 2
  • 12
  • 26
20
votes
5 answers

rest_api_init event not fired

I am trying to run custom plugin on wp 4.7.4 . Below is my simple plugin add_action( 'rest_api_init', 'register_routes'); function register_routes() { register_rest_route( 'taxonomy-manager/v1', '/taxonomies/(P[a-zA-Z]+)',…
Anton Putau
  • 632
  • 1
  • 7
  • 31
18
votes
8 answers

web API build with wordpress is showing error of it works sometime on some network and sometime not working
paras shah
  • 861
  • 2
  • 9
  • 23
16
votes
2 answers

WordPress REST API Global Search (API V2)

I am looking for a way to run a global search query across all or multiple post types using WP REST API. I am able to search posts using: http://example.com/wp-json/wp/v2/posts?search=test In turn I am able to search pages using:…
Marc
  • 4,661
  • 3
  • 40
  • 62
14
votes
1 answer

Can I use the REST API for a site hosted on WordPress.com

I have a blog hosted on WordPress.com. When I try to make a GET request to retrieve the posts I get a 'Not Found' html page. https://alexkojin.wordpress.com/wp-json/wp/v2/posts I know about the legacy public API but it doesn't allow me to retrieve…
Alex Kojin
  • 5,044
  • 2
  • 29
  • 31
14
votes
1 answer

Fetching drafts forbidden in Wordpress rest api

I am using the wpapi npm module to interface with the WP rest api in a node app. I am authenticated and my user created some draft posts. When I go to the dashboard with the same credentials, I can see/edit the draft posts as well. I am using this…
motleydev
  • 3,327
  • 6
  • 36
  • 52
14
votes
5 answers

How do you add custom fields defined in posts to the rest API responses in wordpress

I want to do this without using any sort of plugin since these are both core wordpress features (custom fields and the REST API). Here is the documentation for custom fields for reference: https://codex.wordpress.org/Using_Custom_Fields Here is a…
quinn
  • 5,508
  • 10
  • 34
  • 54
14
votes
4 answers

Pass String Parameters to WP REST API

I can pass integer values to WP REST API. But, cannot pass non-numeric characters. It gives error. This is what I used... add_action( 'rest_api_init', function () { register_rest_route( 'crowdapi/v1', '/register/(?P\d+)/(?P\d+)',…
Tharindu Thisarasinghe
  • 3,846
  • 8
  • 39
  • 70
13
votes
2 answers

How to include META fields in Wordpress API Post?

I am using Wordpress version 5.2.1 which means I am not using a plugin for the WP API. I have working code which creates a new post (using a custom post type) on my WP site, all good there. The problem is that i've created custom fields using ACF,…
Peter Foti
  • 5,526
  • 6
  • 34
  • 47
13
votes
4 answers

WP REST API v2: Getting posts by post ids

I'm trying to get all posts by ID's using WP REST API. As per the documentation, we can use filter to use WP Query arguments. Using this with posts end point returns all the…
Prashanth
  • 518
  • 1
  • 8
  • 21
12
votes
3 answers

WP_REST_Response to download a file

Is it possibile to return a document (a generated PDF, a CSV) using the WP_REST_Response in WordPress? So far I've been registering a custom endpoint using register_rest_resource but if I try to return a file (e.g. using PHP fpassthru($f) or…
Diego Viganò
  • 163
  • 1
  • 10
1
2 3
99 100