REST API
Enable, authenticate, and call all WP ULike Pro REST endpoints — routes, params, responses, and errors.
WP ULike Pro exposes a REST API for votes, user activity, and statistics — for mobile apps, headless front ends, and internal dashboards.
Configure under WP ULike → Tools → REST API. Panel settings export with settings backup; API keys do not.
Base URL:
https://yoursite.com/wp-json/wp-ulike-pro/v1
Namespace: wp-ulike-pro/v1
Extend routes: add_action('wp_ulike_pro_rest_api_routes', function($controller) { ... });
Setup
- Toggle Enable REST API.
- Choose Authentication type:
login— Application Passwords or cookie auth; respects readable/writable role liststoken— Bearer token from generated API keys
- Set Readable routes roles and Writable routes roles (default:
administrator). - Optional: Auto user ID — write operations use authenticated WordPress user instead of body
user_id.
Send Bearer auth:
Authorization: Bearer YOUR_TOKEN
Routes overview
| Method | Endpoint | Permission | Purpose |
|---|---|---|---|
GET | /vote | Read | Paginated vote logs |
GET | /vote/{item_id} | Read | Counters or raw logs for one item |
POST | /vote | Write | Create a vote |
PUT, PATCH | /vote | Write | Update vote (collection) |
PUT, PATCH | /vote/{item_id} | Write | Update vote for one item |
DELETE | /vote/{item_id} | Write | Remove a vote |
GET | /user-status/{user_id} | Read | User vote status on one item |
GET | /user | Read | Top users / voters |
GET | /user/{id} | Read | Single user's voting history |
GET | /stats | Read | Dashboard datasets |
Common parameters
Content type (type): post, comment, activity, topic
Status: like, unlike, dislike, undislike
Factor: up, down (like vs dislike direction on write)
Pagination: page (default 1), per_page (default 10)
WordPress returns X-WP-Total and X-WP-TotalPages headers on list endpoints.
GET /vote — list logs
| Param | Default | Description |
|---|---|---|
type | post | Content type |
page | 1 | Page number |
per_page | 10 | Results per page |
search | — | Search string |
curl -u "admin:APPLICATION_PASSWORD" \
"https://yoursite.com/wp-json/wp-ulike-pro/v1/vote?type=post&per_page=20"
GET /vote/{item_id}
| Param | Default | Description |
|---|---|---|
type | post | Content type |
output | logs | logs = raw rows · data = counters + likers |
Example response (output=data):
{
"like_amount": 42,
"dislike_amount": 3,
"likers_list": ["1", "5", "12"]
}
POST /vote — create vote
| Param | Required | Default | Description |
|---|---|---|---|
item_id | yes | — | Item ID |
user_id | yes* | — | WordPress user ID (*optional if Auto user ID on) |
type | yes | — | Content type |
status | no | like | Vote status |
factor | no | up | up or down |
user_ip | no | 127.0.0.1 | Guest IP when logging anonymous votes |
curl -X POST -H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-d '{"item_id":123,"user_id":1,"type":"post","status":"like","factor":"up"}' \
"https://yoursite.com/wp-json/wp-ulike-pro/v1/vote"
Success response:
{
"status_code": 3,
"counter_value": "43",
"message": "..."
}
PUT/PATCH /vote/{item_id} — update
Same body as POST. Updates existing log and recalculates counters.
Use collection PUT /vote when updating without item ID in URL.
DELETE /vote/{item_id}
Removes the vote identified by body params (item_id, user_id, type, status). Decrements counters and updates likers list.
GET /user-status/{user_id}
| Param | Required | Description |
|---|---|---|
item_id | yes | Item being checked |
type | yes | Content type |
Returns status string: like, dislike, etc.
GET /user — top voters
| Param | Default | Description |
|---|---|---|
type | post | Content type filter |
status | like | Vote status |
period | all | Time period |
order | DESC | ASC or DESC |
page, per_page | — | Pagination |
GET /user/{id} — user history
Same filters as /user for a single WordPress user ID — paginated list of items they voted on.
GET /stats — dashboard datasets
| Param | Required | Description |
|---|---|---|
dataset | yes | Dataset identifier (see full list below) |
start_date, end_date | no | Y-m-d range |
status | no | Vote status filter |
filter | no | Comma-separated post types |
All dataset values
Global counts:
count_all_logs_allcount_all_logs_todaycount_all_logs_yesterdayget_top_likers
Posts:
dataset_ulikeget_top_postscount_logs_ulike_week,count_logs_ulike_month,count_logs_ulike_year,count_logs_ulike_all
Comments:
dataset_ulike_commentsget_top_commentscount_logs_ulike_comments_week,_month,_year,_all
BuddyPress activities:
dataset_ulike_activitiesget_top_activitiescount_logs_ulike_activities_week,_month,_year,_all
bbPress topics:
dataset_ulike_forumsget_top_topicscount_logs_ulike_forums_week,_month,_year,_all
curl -H "Authorization: Bearer TOKEN" \
"https://yoursite.com/wp-json/wp-ulike-pro/v1/stats?dataset=get_top_posts&start_date=2026-01-01&end_date=2026-06-30"
WordPress core REST: votes_info field
When Standard Meta Data is enabled, native WP REST includes vote data on posts and comments:
"votes_info": {
"like_amount": 42,
"dislike_amount": 3,
"likers_ids": [1, 5, 12]
}
GET /wp-json/wp/v2/posts/{id} · GET /wp-json/wp/v2/comments/{id}
See Database & Meta.
Error responses
| HTTP code | Typical cause |
|---|---|
401 | Missing or invalid auth |
403 | User role not in readable/writable list; REST disabled |
404 | Item or route not found |
400 | Missing required param ( dataset, item_id, etc.) |
WordPress REST error body:
{
"code": "rest_forbidden",
"message": "Sorry, you are not allowed to do that.",
"data": { "status": 403 }
}
Security checklist
- HTTPS only
- Enable writable routes only when your app must cast votes
- Prefer Bearer tokens for server-to-server; rotate keys after import or staff changes
- Restrict readable/writable roles to trusted roles
- Never expose tokens or Application Passwords in front-end JavaScript
- Regenerate API keys after settings import — keys are not in backup
Free plugin REST
Free WP ULike registers one authenticated route for the block editor:
GET /wp-json/wp-ulike/v1/templates— template list (requiresedit_posts)
Public vote writes use Front-End AJAX, not REST.
Related: Bulk Actions, GDPR & REST panel · Developer Functions
Related articles
Continue with these guides
Did this article help?
Pick how you feel, add a note if you want, then hit Send. It takes two seconds and helps us improve this guide.