Web-API [v4] - AdminPanel & RESTful web server [now with screenshots!]


Hey guys

Just wanted to give you all a little update.
I'm sorry about the delay, with the holidays going on and my exam session drawing nearer I have been very busy lately.
I'm not sure I will be able to post the update until after new year, but I will try my best.

Sorry about the delay, and thanks for understanding


I don't know whats going on but every api appears to work except the cmd api where all I am getting in return is a 404 not found. Both get and POST just returns {"code":404,"message":"Not Found"}


Hey guys

I was finally able to update the plugin, it is now on version 1.4!
The potential problems with concurrent access to data objects should be fixed (not very nicely, but that will be done in a future update).
I also added the entity and tile entity endpoints to Redoc.
Entities, tile entities, players and worlds now also provide their "raw" data, which should be most of the attached data converted to json. I'm still looking for a better way to do this, but haven't really found one yet.



Hello everyone

I was able to release another update (version 1.6) which offers access to the raw data (basically just java-to-json converted) objects, and invocation of methods on those objects. This is not yet thread-safe and still in development.




Glad to know you're still working on this :slight_smile:
Really enjoying the documentation on https://valandur.github.io/Web-API/redoc.html looks amazing, although wish you could provide some examples for each.


Thank you for the kind words @tridaak
I can most certainly add more examples - I'm assuming you mean example replies that the server would give to certain endpoint requests, especially the "raw" endpoints as they have barely any documentation?
Just keep in mind that in case I add examples for the above, they will be only partly correct, because the actual data would depend on a few things including the mods running on your server.


Hmm, so right now testing it out, seems pretty neat. Would've liked more information about connecting, because the GET POST stuff on here confused me: https://valandur.github.io/Web-API/redoc.html
Thought I needed to send some variables when checking chat and stuff.

Also, wanted to let you know that chat doesn't seem to be working properly, at least for me. Maybe it's because nucleus is handling the chat :?
For '', I get back "{"messages":[{},{}]}", empty strings for player messages. Seems that /broadcast /say and other chat commands doesn't count as chat. (Wanted to use this to handle messaging from the website, so that I didn't need to get on console)

Also, would it be possible to add player count per world?


Chat thing might be because Im using 1.10.2
I downgraded to v1.3, and chat is working ok. But /say and /broadcast don't show up.


Sorry for all these messages. Im just finally getting to test all of this and it's amazing. Oh man, this is just wonderful. Previously, how I was handling things was, php would write to a text file, where I'd have a cron job run every 10 seconds, executing a script that run all the commands in the text, oh man, that was now pointless and very badly implemented.

I was wondering if there's any way to change the name of the "Web-API" when running commands onto something else, when running a command it'll say [Web-API has run ___] Or on /say , it says [Web-API] ____


Hey @tridaak, I'm going to look into the issues with the chat, it might depend on how other plugins handle chat messages.
As for the name when running commands - I was thinking about adding the possibility to "sudo" commands, as if they're coming from players. I don't know if changing the name to anything arbitrary is possible, but I'll take a look.


Awesome, thanks :slight_smile:
Right now I'm using nucleus, that handles the chat as well as direct messages to players, broadcast, etc.

  1. Are future updates just gonna be for 1.11 or will the 1.11 jar work on 1.10? Since sponge 6.0.0 is still on it's "experimental" phase.

  2. Would it be possible to also include output from things such as social spy (or even command spy).

  3. Not sure if there's this problem with the latest version, since I'm still using the web API 1.3 (because it's 1.10, and had problems with the latest with the chat), but when I run a command for a plugin that runs on a different thread, I don't get any output from the command (even though the command does run). Seems I only get output if the response is on the Server Thread. (I could be wrong about this, but what I've observed so far.)


Hey everyone

I have released a new version of the Web-API, 1.9, with the following major changes:
- "Naming" the Web-API commands (so that it doesn't say [Web-API] ... when running a command - add the name property to your post object)
- Viewing the command execution history (available at http://[server-url]/api/cmd/history). This endpoint shows past commands ran on the server
- Fixed chat and rate limit

@tridaak: I have added a version targeting sponge 5.1.0 on github releases, but I believe the 6.0.0 version should also work for you.


Awesome, it works great. Chat is working now (although not sure if it should include the prefix and name in the message):

string(681) "{"messages":[{"date":1488337726,"sender":{"name":"Tridaak","uuid":"57838f9a-6cfe-4873-aa81-3337d1ff3d04"},"message":"You are not allowed to log in to this server."},{"date":1488337726,"sender":{"name":"Tridaak","uuid":"57838f9a-6cfe-4873-aa81-3337d1ff3d04"},"message":"Tridaak joined the game"},{"date":1488337748,"sender":{"name":"Tridaak","uuid":"57838f9a-6cfe-4873-aa81-3337d1ff3d04"},"message":"[Dadmin] Tridaak: Hi"},{"date":1488338174,"sender":{"name":"Tridaak","uuid":"57838f9a-6cfe-4873-aa81-3337d1ff3d04"},"message":"[Dadmin] Tridaak: Hi"},{"date":1488338258,"sender":{"name":"Tridaak","uuid":"57838f9a-6cfe-4873-aa81-3337d1ff3d04"},"message":"[Dadmin] Tridaak: say Hi"}]}"

Broadcast and say don't show up, but no biggie.

Naming commands is working wonderfully, really will help out a lot, not only does it look nicer for users (Ie, When sending codes and stuff to user, it used to say Web-Api was sending the message, now I can make it say the server sends the message), but also helps out sorting the commands. I can run commands under the name of "Web-Store" for a website shop or "Vote rewards", and this can help me keep track of the commands being run. Thanks a ton for adding this!

There is still a problem trying to get the output from certain plugins/mods. Seems it's just mods/plugins whose output isn't on [Server thread], have tried it more, commands from luckperms, economylite, nucleus don't give an output.
On console, when I run the command through there, I get: [04:38:07] [pool-2-thread-57/INFO]: Tridaak's Balance: 18,188.00 Poke-Dollars
While with web api, no output is returned (just empty array).
While plugins that run on main thread, like pixelmon commands and serious vote, work perfectly fine: array(1) { [0]=> string(42) "You have successfully given Tridaak a vote" } (Running that same command from console outputs: [04:39:04] [Server thread/INFO]: You have successfully given Tridaak a vote)

If I come across any other problems, I'll let you know! Thank you so much for making this plugin :slight_smile:


Oh and you should also put a donate link on here. I'm sure people who use the plugin and find it as useful as I do will want to donate.


I'll take another look at the comand output from plugins, it might be a Sponge thing, I'll take a closer look.

As for the broadcast and the say commands, try looking at the /cmd/history endpoint, they'll probably show up there. I was thinking about merging command and chat history for that reason, but in general it doesn't make much sense to do that, since there might be other commands in the command history.


Awesome, also, had a pretty dandy idea. IDK how hard it'd be to implement however or if it's possible, but if it is, then would open a bunch of possibilities :open_mouth:

Would it be possible for the plugin to send a post request (with a code for verification) to the webserver from minecraft. So, lets say I want to give you special website access from the game (lets say the user did something to trigger a command, like possibly run a special command kit), then a command would be run along the lines of "/web-api send {"code":"Superadmincode","request":"give-access-hidden"} " with it, gets send those variables along with a target (@p) variable. Web-Api can check the code (if ya want, wouldn't really matter much at this stage, since would need to be checked later on from the server to make sure the command is allowed.

Similarly to how paypal sends payment confirmation messages to the server when one has IPN enabled.

The place it gets sent to would be configured in the configuration file. And from there, there'd be a script that accepts and receives data, checks the post data, checks if the confirmation code is valid, checks the variables, such as request and target to figure out what to do, and possibly checks other variables that are sent to the web server.
That way, if it's something that affects that player, @p can be used, if it's something that's meant to affect another player, {player:tridaak} or something can be used.


I'm sorry but I'm not quite sure I understand what you're trying to say.
The WebAPI sends a code/link in-game to a player (due to a kit or a trigger or whatever) and the player can then use that code (paste it in a browser/use it on a webpage) to do what exactly? And where does it go afterwards?
Does it get sent to another webserver/endpoint (non Web-API)?


So, web API is currently used for the webserver to send data to the minecraft and gets a response according to what's being asked.
However, minecraft currently has no direct way of communicating with the webserver.

Long example:
What I'm asking is to add that. So that really the server (and plugins), not users, can use that to send data to the web server from the game. I'm running a pixelmon server, so let's assume I want badges to show up on the website when a gym leader is beat. So, I add a trainer command to the NPC Gym Leader.
This command would be something along the lines of "/web-api send {"code":"Superadmincode","request":"newBadge", "badge":"rockBadge"}"
WebAPI would then send a POST request to a certain part of the website, lets assume www.domain.com/webAPI/receive.php with the following data:
Code: Superadmincode
Request: newBadge
Badge: rockBadge
Target: @p (player's UUID or their username)

receive.php gets the post request (they can use htaccess or $SERVER['SERVERADDR'] != $SERVER['REMOTEADDR'] to make sure request is coming from localhost or some other acceptable domain)
Then it checks the code or key, in this case if it's equal to Superadmincode, if not equal to that, die with a failure value, if equal continue.
Then checks what the request is about, in this case, newBadge so it knows that the request is to add a badge to the player's account. It then checks for the badge and target values, if both good, it adds them to a database; and dies with a success output, if either are bad, dies with a failure output (ie: die("Badge could not be found"))

WebAPI gets whatever data is outputted, limited to a certain character limit (in case it's not properly configured, wouldn't want a whole 404 page to get sent) and sends that to the player.

This could be used in conjunction to many different cases. Let's assume I have a seriousVote, one of the vote rewards is 10 vote tokens another is 100, which can be used on the website to select certain vote rewards. Data gets sent to the webserver and added to a database for the user to spend on a vote shop on the website.
Quite literally, you put this together with aliases, the server admin can make various different new commands and interact with many different parts of the server and webserver with just knowledge of php or some other backend webdevelopment language.
Since webAPI would provide a way to communicate to the webserver and back, and aliases can give each new command a new name.

Ie: More complex: Player has recently bought something from the shop, but wasn't online to receive it, luckily enough, server keeps all undelivered purchases in a database.
Player runs /redeem (which is an alias for "/web-api send {"code":"Superadmincode","request":"redeemPurchase"}"), webserver then checks database if any purchases are made, if so, takes them from the database, uses webAPI to deliver all the items or other stuff, once it's all complete, it tells the player the output (which would be either "You have received your purchase! Thank you for supporting Server" or "You have no items pending to be delivered!")


I have completed a large update for the Web-API, version 2.0.


Also there might be new bugs that weren't there before, and I haven't had quite enough time to find them.
This is also why it is currently only on github releases, and not on Ore yet.

Anyone using Sponge 5.1 will probably have to switch to the Sponge 5.1 build, as the "type" attribute of the achievements seems to be new in Sponge 6.0

@tridaak I have implemented a first version of what you suggested (a very good idea btw :smile:)
Since I haven't had enough time to document it, most of the info is in the new hooks.conf file. I will add more/better info as soon as I can.


Oh man, can't wait to try it out :slight_smile:
Opens so many new possibilities for me. Thank you!