Skip to content

How to Get Started with WP ULike REST API?

How to Get Started with WP ULike REST API?

In the application and web services era, it is hard to ignore the importance of data transfer between online sources. Many web developers and programmers hit that roadblock in their time. but in WP ULike we developed a way to ease that pain. WP ULike now supports the Rest API for extracting data.

before getting deeper in configuration lets see how Rest API works.

What is the REST API?

An API is an application programming interface. It is a set of rules that allow programs to talk to each other. The developer creates the API on the server and allows the client to talk to it.

REST determines how the API looks like. It stands for “Representational State Transfer”. It is a set of rules that developers follow when they create their API. One of these rules states that you should be able to get a piece of data (called a resource) when you link to a specific URL.

Each URL is called a request while the data sent back to you is called a response.

The Anatomy Of A Request

It’s important to know that a request is made up of four things:

  1. The endpoint
  2. The method
  3. The headers
  4. The data (or body)

The endpoint (or route) is the URL you request for. It follows this structure:

root-endpoint/?

The root-endpoint is the starting point of the API you’re requesting from. The root-endpoint of Github’s API is https://api.github.com while the root-endpoint Twitter’s API is https://api.twitter.com.

The path determines the resource you’re requesting. Think of it like an automatic answering machine that asks you to press 1 for service, press 2 for another service, 3 for yet another service and so on.

How does REST API work on WP ULike?

Many of our users asked for a solution to extract and transfer data in JSON format. Therefore, we added Rest API compatibility to our plugin. you can access this feature from Setting> Developer Tools> Rest API.

Rest API in WP ULike plugin

As you can see, the integration is quite simple on this side. You need an Authentication method to transfer data. We use and recommend JWT Authentication for WP REST API. this plugin Extends the WP REST API using JSON Web Tokens Authentication as an authentication method.

JSON Web Tokens are an open, industry-standard RFC 7519 method for representing claims securely between two parties.

You can also use your own authentication solution with Custom Keys.

Also, you can easily manage who can have access to readable and writable roots in this section.

You can see an example of using Rest API to transfer data from WP ULike Log in the picture below:

Extract data with Rest API in WP ULike plugin

Let’s talk about using the Endpoints

Get All Votes

Example Definition: GET http://yoursite.com/wp-json/wp-ulike-pro/v1/vote

Parameters:

  • type: Select collection type between post, comment, activity & topic. (Default: post)
  • page: Current page of the collection. (Default: 1)
  • per_page: Maximum number of items to be returned in result set. (Default: 10)
  • search: Limit results to those matching a string.

Create a New Vote

Example Definition: POST http://yoursite.com/wp-json/wp-ulike-pro/v1/vote

Parameters:

  • item_id: Select item ID.
  • user_id: Select user ID.
  • type: Select collection type between post, comment, activity & topic.
  • user_ip: Select user IP.
  • status: Select voting status. (Like, Liked, Dislike, Disliked)

Update Vote Status

Example Definition: PUT http://yoursite.com/wp-json/wp-ulike-pro/v1/vote

Parameters:

  • item_id: Select item ID.
  • user_id: Select user ID.
  • type: Select collection type between post, comment, activity & topic.
  • status: Select voting status. (Like, Liked, Dislike, Disliked)

Get Single Vote

Example Definition: Get http://yoursite.com/wp-json/wp-ulike-pro/v1/vote/1

Parameters:

  • id: Select vote ID.
  • type: Select collection type between post, comment, activity & topic. (Default: post)

Update Single Vote

Example Definition: PUT http://yoursite.com/wp-json/wp-ulike-pro/v1/vote/1

Parameters:

  • id: Select vote ID.
  • item_id: Select item ID.
  • user_id: Select user ID.
  • type: Select collection type between post, comment, activity & topic.
  • status: Select voting status. (Like, Liked, Dislike, Disliked)

Get Top Users List

Example Definition: GET http://yoursite.com/wp-json/wp-ulike-pro/v1/user

Parameters:

  • type: Select collection type between post, comment, activity & topic. (Default: post)
  • page: Current page of the collection. (Default: 1)
  • per_page: Maximum number of items to be returned in result set. (Default: 10)
  • order: Select order type between DESC, ASC (Default: DESC)
  • status: Select voting status. (Like, Liked, Dislike, Disliked)
  • period: Select date range period. (Default: all)

Get User Data

Example Definition: GET http://yoursite.com/wp-json/wp-ulike-pro/v1/user/1

Parameters:

  • id: Select user ID.
  • type: Select collection type between post, comment, activity & topic. (Default: post)
  • page: Current page of the collection. (Default: 1)
  • per_page: Maximum number of items to be returned in result set. (Default: 10)
  • order: Select order type between DESC, ASC (Default: DESC)
  • status: Select voting status. (Like, Liked, Dislike, Disliked)
  • period: Select date range period. (Default: all)

We need Your help!

Despite our best efforts, there will be bugs or issues with WP ULike Root for REST. so, please report these problems via Support Service.

On the other hand, there is always room for improvement for us and we will appreciate any suggestions and ideas to make our product better.

was this article helpful?
15
3
Share on facebook
Share on linkedin
Share on twitter
Share on telegram
Related Posts
Comments

No comment yet, add your voice below!


Add a Comment

Your email address will not be published. Required fields are marked *

Want to create ultimate user profiles?