Sueta

Web Restful API for PvpTitles

1.0-SNAPSHOT

let you to access rank data in website without connect to mysql

·Plugin

If you are lazy or don't know how to make an restful server that take your rank data from mysql, then this plugin may help you.

Dependencies
This plugin using javalin as restful libraries that you just need to install pvptitles as dependency then this plugin will work on the background.

How to use
here's the config.yml

# the port that restful will run on   
web-port   :  7000 
 # whether to allow all IP access your restful   
cors-enable-all   :  true 
 # if not, specifics some IPs   
cors-allowed-list   : 
  - 127.0.0.1 
 # max limit of players data of pvptitles   
max-limit   :  100 

 # the token value will generate after the server run  
 # if you remove the path, it will auto generate the new token  
 # the token only need to be used when refreshing data  
 # after refreshing data, it will auto generate a new token and save to the config   
token   :

let your website to be http://localhost/
if your web port is 7000
then your restful url should like http://localhost:7000/

Supporting paths

GET: /list ?limit=<number> - return a list of player data with a limited number
query parameters:

  • limit: the max limit
  • start (optional) : the rank index to start getting from, default 0

showcase: (caz i only have one data :p )


GET: /info/<uuid> - return a rank info of that player
no query parameters

showcase:

POST: /refresh - clear the caches of rank data and renew it. The request /list and /info are just getting the caches from plugin but not getting real time data. If you wish to clear the old caches and cache a latest data, use this request.

body parameters:

  • token: you must use the token in your config.yml to access this operation.

response:

  • new-token: the new generated token that saved in your config.yml
  • success: whether the caches has refreshed successfully

showcase:
YouTube

Attention
sometimes you may get an Exception like this

Actually, it is an exception in java. For example, the reason you got this exception is because the data size is only 1, but you set the starting index to 5.

If you want more details (usually for developer to debug), try to add a query parameter "debug=true", then you will get like this

If you want to access the data from other host, make sure you have exposed a port for this!

Similar projects

Plugin →