WordPress JSON API returns only 404 errors

You have the wrong address. According to the documentation, the following are valid links:

Implicit mode examples:

  • http://www.example.org/?json=1
  • http://www.example.org/?p=47&json=1
  • http://www.example.org/tag/banana/?json=1

Explicit mode examples:

  • http://www.example.org/?json=get_recent_posts
  • http://www.example.org/?json=get_post&post_id=47
  • http://www.example.org/?json=get_tag_posts&tag_slug=banana

With user-friendly permalinks configured:

  • http://www.example.org/api/get_recent_posts/
  • http://www.example.org/api/get_post/?post_id=47
  • http://www.example.org/api/get_tag_posts/?tag_slug=banana

Source: https://wordpress.org/plugins/json-api/other_notes/

So in your case you should use http://localhost/wordpress/api/get_recent_posts/


Old question and answer, but for anyone coming here recently via search results (like me), /wp-json/posts should at least bring a JSON result (albeit still a 404 error), and /wp-json should list some available routes in JSON.

If it doesn't (e.g. it shows an Apache or other 404 error page), it's probably a permalinks issue


It is an mod_rewrite issue.

Reason is one of these in your .htaccess:

  • not existing
  • wrong permissions
  • screwed up

Try the htaccess documentation on Wordpress for your .htaccess:

## BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Tags:

Json

Wordpress