How To Install WordPress REST API To Find Articles


how-to-install-api-wordpress-rest-de-heart-viet

How to install the WordPress REST API to find articles - Before talking about the technical aspects of using the WP REST API, it is important to recall the basics.


API stands for Application Programming Interface. API is an automated approach to connecting to application data. For example, the Facebook API showcases a range of features from the Facebook platform.


REST stands for state representation. The API is considered to be REST if the design from it registers to a specific constraint set including server-client mechanism, independent deployment, and options for scalability.


The request for feedback together constitutes an additional component of how HTTP works.


how-to-install-api-wordpress-rest-de-heart-viet


  • Each client makes 1 HTTP request to 1 server

  • The server responded with the HTTP response

In HTTP, this mechanism works by using GET (Request), POST (Feedback).


how-to-install-api-wordpress-rest-de-heart-viet


Routes and endpoints


Note that in the first example, we used the following endpoint:


GET wp / v2 / article


The endpoint is accessible via API and then they act as restore post to create other users or update post meta. On the other hand, we say the endpoint triggers the technique to perform the specific task. These endpoints must follow the HTTP verb connected to them. In the above case, we are using the GET verb to recover the entire article.


Routes with the above terminals are the following:


wp / v2 / article


Course is basically the name to go to the end point. The course is likely to have multiple endpoints from an HTTP verb perspective, so the course has an accompanying endpoint for creating other posts:


POST wp / v2 / article


This endpoint, when activated with the supplied parameter, will create a new post entity.


Consider the following Routes:


This route points to the Post id of 50. It has the following three endpoints:


  • GET wp / v2 / article / 50: used to retrieve posts with id 50. It activates get_item () method.

  • PUT wp / v2 / post / 50: use update post with id 50. It activates update_item ()

  • REMOVE wp / v2 / posts / 50: It deletes the post with id 50. It activates the delete_item () method.

See more: who saw your news on facebook


The WordPress REST API uses JSON


REST, JSON together provide components to create applications capable of using WordPress back-end. The most important case, the mobile application requires information exchange between the client and the server.


Because JSON is a text-based format to remove information, it is perfectly used with most programming languages. Therefore, JSON acts as a worldwide connector when transacting information between different stages of similar decoding by both machines and people.


Using the same API as the one being discussed, WordPress website content is not limited to itself but accessed by websites and other client applications. Because the API displays some internal functionality, the remote client interacts with the website to update or create new content. It also agrees to grab content from an existing WordPress website and display it on several other websites.


Using the same API as the API being tested, WordPress website content is not limited only, but only received by different destinations. When the API discovers some usefulness inside, the remote customer communicates with the website to redesign or create new content. It also agrees to restore content from the current WordPress website and then display it at another website.


You should have a solid idea of ​​what WP API is capable or what are the limitations in it. I show you steps regarding working with it. First of all, you need to add the WP API plugin to your WordPress website.


At that time, log in to the WordPress website (your-site-name.com/wp-login.php). However, the plugin is in the left sidebar and then click add new. Click the Upload plugin button, click the file, then select the WP API plugin compression version, then click install now.


how-to-set-api-wordpress-rest-de-heart-viet


That's everything involved in configuring the WP REST API. Now, we have access to interesting content and receive data from the WordPress website using the WP API.


Example WP API REST


We show you an example of an unverified WP API GET request. So no need to worry about any plugins or authentication settings.


Start by adding the Chrome Postman extension. You also install the REST easy add-in if you use Firefox.


Get the article


We show you how to download all existing posts at your WordPress website. To do this, copy the following URL:


http: //www.your-web-site.com/wp-json/wp/v2/posts


Paste that Routes into the required input field of Postman URL. You can also do this by writing Routes in a web browser, but the data will not be organized, so the map view will be more difficult. Replace ‘your-web-site.com’ with the website where you introduced the WP API plugin. Select Receive from the drop down menu and click Submit.


how-to-install-api-wordpress-rest-de-heart-viet


This is sending a GET request to the WordPress website server, which is sending a response based on the Routes with the HTTP action set. You should see a JSON response similar to the one below.


how-to-install-api-wordpress-rest-de-heart-viet


Obviously, this feedback is actively organized so you don't get stressed out, often taking the information within it. This is really important structure because it agrees you to change the data programmatically.


Get a post


Now that you know how to get a list of posts on a website, we will show you how to receive specific posts from the WordPress website with the WP API plugin installed. Copy the link below.


http: //www.your-web-site.com/wp-json/wp/v2/posts/ {id}


Paste it into the Postman field enter the URL request here. Again, make sure you select GET from the drop down menu. Replace your-web-site.com with the website where you installed the WP API plugin on AND replace {id} with the post ID you know exists on WordPress website.


how-to-install-api-wordpress-rest-de-heart-viet


As you can see, there are no left square brackets to start feedback. Specifically, this response includes all post data related to posts with an ID of 5. The individual post data is in the same format as the post list above. You can analyze by feedback, view post id, post title, post content, post excerpt and many other post details.


Epilogue


Above, we discussed how to use the WordPress REST API to find posts. If you have any questions, leave a comment below.


About My name is Nguyen Manh Cuong. I was born in a poor village in Ba Vi district, HA NOI province - windy and sunny land. Currently. https://www.nguyendiep.com/. Mr Cuong.
Newer Posts Newer Posts Older Posts Older Posts

Comments

Post a Comment