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)

Get Statistics Data

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

Parameters:

  • dataset: Select the type of data from the following options:
    1. count_all_logs_all
    2. count_all_logs_today
    3. count_all_logs_yesterday
    4. get_top_likers
    5. dataset_ulike
    6. get_top_posts
    7. count_logs_ulike_week
    8. count_logs_ulike_month
    9. count_logs_ulike_year
    10. count_logs_ulike_all
    11. dataset_ulike_comments
    12. get_top_comments
    13. count_logs_ulike_comments_week
    14. count_logs_ulike_comments_month
    15. count_logs_ulike_comments_year
    16. count_logs_ulike_comments_all
    17. dataset_ulike_activities
    18. get_top_activities
    19. count_logs_ulike_activities_week
    20. count_logs_ulike_activities_month
    21. count_logs_ulike_activities_year
    22. count_logs_ulike_activities_all
    23. dataset_ulike_forums
    24. get_top_topics
    25. count_logs_ulike_forums_week
    26. count_logs_ulike_forums_month
    27. count_logs_ulike_forums_year
    28. count_logs_ulike_forums_all
  • start_date: Select start date. (Format: Y-m-d)
  • end_date: Select end date. (Format: Y-m-d)
  • status: Select voting status. (like, dislike, unlike, undislike)
  • filter: Select post types filter. (separate items by comma)

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.

Make your website more attractive and user-friendly with WP ULike

was this article helpful?
Related Posts
Comments

Leave a Reply

Your email address will not be published.

Want to create ultimate user profiles?