wordpress api get posts 1

wordpress api get posts

curl http://yourdomain.com/wp-json/wp/v2/posts

Here is what the above code is Doing:
1. We’re using the requests library to make a GET request to the URL we want to scrape.
2. We’re using the json library to parse the JSON response we get from the API.
3. We’re using the pprint library to make the output a little easier to read.
4. We’re using the open() function to create a new file called posts.json.
5. We’re using the json library to write the JSON response to the posts.json file.

Similar Posts