Badges
Badges

Knowledge Base

This documentation is for the WooRewards plugin

Read the list of badges

Use the standard WordPress REST API to read the badges.

GET
/wp-json/wp/v2/lws_badge/

See WordPress documentation for more information.

Get a user’s badges

Use this API route to get a user’s badges. It requires only the user reading permission.

GET
/wp-json/woorewards/v1/badges/<user_email>

Available parameters

  • user_email : (string) – A user email.

Response

The JSON response is an array of status object. That object contains at least the following properties:

  • badge_id : The badge’s identifier.
  • assign_date : The date the user got it.

Error cases

A 403 error is raised if logged in user is not the requested one or has no capabilities to read other user’s data.

A 404 error is raised if the user cannot be found by email.

Get the users that own a given badge

Use this API route to get a user’s badges. It requires the user reading permission.

GET
/wp-json/woorewards/v1/badge_owners/<badge_id>

Available parameters

  • badge_id : (int) – A post identifier.

Response

The JSON response is an array of user’s identifier.

Error cases

A 403 error is raised if logged in user has no capabilities to read other user’s data.

A 404 error is raised if the badge cannot be found.

Get a badge rarity information

Use this API route to get a badge’s statistics. It requires the general reading permission.

GET
/wp-json/woorewards/v1/badge_rarity/<badge_id>

Available parameters

  • badge_id : (int) – A post identifier.

Response

The JSON response is a status object. That object contains at least the following properties:

  • rarity : The rarity level name.
  • percentage : (float) The percentage value is the max percentage of users owning the badge to get the corresponding rarity.

Error cases

A 404 error is raised if the badge cannot be found.

Was this article helpful?
Dislike 0
Views: 53

Continue reading

Previous: Get a user’s points
Next: Add/Subtract Points