How to generate an API url to get data from Wordpress blog

387 Views Asked by At

Currently, I want to get data from my personal blog on WordPress to put through my personal website. I tried using this URL: https://shopssam.wordpress.com/wp/v2/posts and it didn't work. After a while of researching, there must be more tweaks in PermaLinks. And I can't find it anywhere in the WordPress home page settings.

2

There are 2 best solutions below

1
Reza Kia On BEST ANSWER

wordpress.com use different REST API than normal wordpress.org.

First find your Site ID from link bellow: https://dashboard.wordpress.com/wp-admin/index.php?page=my-blogs

Then replace SITEID in below parameter to get all posts: https://public-api.wordpress.com/rest/v1/sites/{YOUR_SITE_ID_GOES_HERE}/posts

0
nguyen sam On

For those who need a clearer answer. You can read the information here: https://developer.wordpress.com/docs/api/. This is a document for Wordpress.com, be careful when using Wordpress, because despite having the same name, WordPress.com and WordPress.org have completely different ways of working. And here is the exact API URL that I modified to get the data: https://public-api.wordpress.com/rest/v1/sites/shopssam.wordpress.com/posts

Which shopssam.wordpress.com is my blog URL.