How to use API
1. Get API key for your server
1.1. Firstly, you need to аdd your server to get it listed in the system.
1.3. Select the server you want and click the on the Edit button.
1.4. On the edit server page, at the right side bar, you will see API integration fields for your server (note that if you have more servers, those keys will be different for each of your servers).
1.4.1. API TOKEN - custom api key for each of your servers.
1.4.2. TOTAL VOTES API link - custom url for prefilled with the correct ID and API KEY for your server.
1.4.3. IP VOTED CHECK API link - custom url for prefilled with the correct ID and API KEY for your server, except the IP address of your visitors/players. You must replace the “IP_ADDRESS” text in the link.
2. TOTAL VOTES API
When you want to check the total votes for your server you have to use the TOTAL VOTES API link (1.4.2). The url should look like this:
Returns JSON response with “server_votes” containing the number (integer) of votes and “response_code” with the http response status code (example: 200)
3. Check if IP address voted
In many cases you may need to check if a player/site visitor has voted for your server in our system - yes we support that too.
To check if an IP address has voted for your server you have to use the IP VOTED CHECK API link (1.4.3) which is automatically generated for your server but you need to change it a bit.
If you follow the instructions (look at “1. Get API key for your server”) and already got your custom link for your server, it should look like this:
Note that at point 3, there is a static text “IP_ADDRESS”, you must replace it dynamically with the player/visitor ip address and then call this url.
When you make the change and you replace the IP_ADDRESS placeholder in your custom url, it should be exactly the same, except if you have now added a real IP address.
Example after change:
This will return a JSON response with the information about when the IP has voted.
Example json response:
- "has_voted" - boolean (true/false) value. Will return “true” if the IP address has voted, otherwise will return “false”.
- “server_time” / “hotserversServerTime” - datetime string showing the current date and time on the server, if you need to make some calculations about the time difference.
- “vote_time” - unix timestamp integer, showing exact time when the IP address has voted; If the IP address hasn't voted, it will return 0.
- “response_code” - returns standard http response code for success - 200 if you called the right url. Otherwise will show the proper http response code for error.
- “response_error” - returns a string showing the error if there is one. Otherwise it will return “false”, signaling there is no error.
Example success json response:
4. Download FREE integration code
We have made it very easy for you. If you need a plug and play solution you can download the script that already includes the right API calls and you only have to replace your Server ID and API TOKEN (check point 1 to see where you can find them).
4.1. New voting reward system source files (version 2) - you can Clone this Repository or better yet star it, fork it, modify it and make it better.
Link to GitHub Repository: https://github.com/nightw0lv/VDSystem
Big thanks to @nightw0lv for maintaining the voting system and working with us to make a seamless plug-and-play integration for you, our most precious players and server owners!
4.2. OLD voting reward system source files (version 1): DOWNLOAD THE ZIP.
1. Your API token is the same for all servers in your account.
2. If you regenerate your API token from your profile, you will need to update the API links for your server in your server integration code. The old links will become invalid, so be careful when you regenerate your api token.
3. The api url address is case sensitive and must be copied exactly as it is shown, or otherwise it will not work.
If you need additional L2 development services, you can use our discount code HOTSERVERS on: https://shop.denart-designs.com/
For more information, please contact us.