EP-JSON-API
Mixture of PHP & MySQL magic to create readable json files for any end-users needs.
Requirements:
- MySQL (prefer 8.0)
- PHP (prefer 7.4)
- WebServer (prefix nginx)
Towny Requirements:
- Towny in MySQL Mode
- Towny 0.96.5.6
Installation
- Create a MySQL user that has READ/SHOW access only to your Towny Database.
- Run the command in Mysql,
CREATE USER 'api'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PASSWORD'
- Run the command in Mysql, `GRANT SELECT,SHOW VIEW ON towny.* TO 'api'@'localhost';
- Run the command in Mysql,
- Drag and drop
includes
andtowny
into your web servers directory.- Configure
includes/config.php
by setting your Host, Username, Password, Database name and Mysql Port. - Configure each
town.php, resident.php, nations.php
variables such as$column = 'towny_nations';
to match your case sensitive database, some databases require you set this as$column = 'TOWNY_NATIONS';
- Configure
- Once configured properly, you should be able to visit your web servers address and call into the
town.php, resident.php, nations.php
files. For example,http://localhost/towny/town.php
API Usage
- Read our documentation for EarthPol's api, (https://earthpol.github.io/dist/api.html)
- You can do
{method}.php?name={townname|resident|nationname}
to get individual data, or abstain for using?name=
and pull all of the data at once.