TrinityCore JSON RESTful API

This software provides an easy to use RESTful API for TrinityCore available via HTTP, which delivers the most important database contents in simple JSON format. It is written using Laravel PHP framework.

Our goal is to build a strong, reliable base on which you can build awesome web applications for TrinityCore (e.g. search engines, visual database editors, server administration tools, armories, etc…).

http://shinworld.altervista.org/images/tc-json-api.png

The JSON API makes it easier to build your web applications, because you do not have to worry about accessing directly the database, and the datas are provided into a very friendly format for front-end web programming languages. Also, a single instance of the TrinityCore JSON API can be a data provider for multiple web applications, even among separated machines.

Example of applications using the TrinityCore JSON REST API:

[ul][li][B]TrinityCore Search Engine[/B] (shows database datas into a web application)[/li]
[li][B]TrinityCore Server Status web page[/B] (shows online players list)[/li]
[li]Keira2 the TrinityCore Database Web Editor[/li]
[li]TrinityCore Ticket Viewer (shows open tickets and statistics about GM who resolved tickets)[/li]
[li]ArenaStats (shows statistics about Arena teams)[/li]
[/ul]

Installation instructions:

https://github.com/ShinDarth/TC-JSON-API/blob/3.3.5/INSTALL.md

Documentation:

https://github.com/ShinDarth/TC-JSON-API/wiki

Live demo:

See live demo here.

Example: http://usefulness.altervista.org/TC-JSON-API/public/index.php/creature/template/30

Future features:

  • All characters and auth useful resources

  • Account-based authentication

  • …post your suggestions!

Released under AGPL license.

Me and +click were thinking about doing something similar to this however it would be the server itself serving the HTTP REST API.

It could have endpoints to list and manage players, guilds, etc, and a bunch of other stats.

This is a simple example of a web front-end application (still much incomplete) that uses the TrinityCore RESTful JSON API.

It’s a (currently)very-primitive search engine for world of warcraft, fetching data from TDB.

This one-page-application is entirely written in html/css/javascript, using AngularJS javascript framework, with no PHP or other server-side languages (the application just perform calls to the API to get the data).

This is a good way to separate different layers: one layer to provide the data (API), and an other one to show it (the web font-end application).

My idea is to have worldserver serve the API instead of making an external server query the database.

This would allow a safer and uniform access to the data and also access to data that the database alone can’t provide.

doesn’t gSOAP already support RESTful APIs ? it’s “just” a matter of esposing methods

I think there are pro and cons for both ways.

Worldserver serving the API

Pros: allow a safer and uniform access to the data and access to data that the database alone can’t provide

Cons: every call to the API is an additional load for the server, one may want to focus all the worldserver machine power to serve the game to players

External PHP API

Pro: easier to install (needs just the database and not the whole TrinityCore installed), can installed even on a separate machine than the worldserver and requires just mysql and a webserver (in short you can install it even in a simple web host, no need of an entire dedicated machine)

Cons: it can’t access to data ta the database alone can’t provide EDIT: it can now fetch data from DBC too

Honestly I don’t know which one I would choose, I think it depends on what I have to do with id. I would probably choose the external API if I have a worldserver already running a big load, while I could prefer the internal one for development purposes.

Indeed at first I thought this was a direct reply to http://www.trinitycore.org/f/topic/11228-rest-on-the-soap-we-want-help-from-you/

Then why not both? /emoticons/default_tongue.png

Release v0.2:

[ul][li]Multiple database connection support[/li][li]All world basic resources[/li][li]Some characters resources[/li][li]Basic search routes with multiple optional parameters[/li][li]Online players[/li][li]Display API and world database version[/li][/ul]

Available now a “full version” download (easier to install).
Installation instructions: https://github.com/S…3.5/INSTALL.md

Release v0.3:

[ul][li]Added new world routes[/li][li]Allow to optionally retrieve extra fields[/li][li]Allow to run API and client web applications among separate machines[/li][/ul]

Installation instructions: https://github.com/S…3.5/INSTALL.md

Download “FULL” version: https://github.com/ShinDarth/TC-JSON-API/releases/download/v0.3/FULL.TrinityCore.JSON.REST.API.0.3.zip

Release v0.4

Changelog:

[ul][li]Implemented smart_scripts routes[/li][li]Added the ‘sqlite’ database to fetch DBC data (taken from Discover-'s SAI Editor)[/li][li]Implemented some DBC routes[/li][/ul]
Notes:

[ul][li]New requirement: PHP Sqlite driver (php5-sqlite)[/li][/ul]

Installation instructions: https://github.com/S…3.5/INSTALL.md

DownloadFULL” version: http://community.trinitycore.org/files/file/22-trinitycore-json-api-full/

Alternative download: https://github.com/ShinDarth/TC-JSON-API/releases/download/v0.4/FULL.TrinityCore.JSON.REST.API.0.4.zip

Release v0.5

Changelog:

[ul][li]Implemented several DBC routes, including Search ones, and 6.x support of most of them[/li]
[li]Implemented *_questitem routes for Creatures and GameObjects[/li]
[li]Implemented quest_template_addon route[/li]
[li]Fit with latest TrinityCore DB structure changes[/li]
[/ul]
Notes:

[ul][li]Requires TDB 335.59 or newer (also TDB.58 with all updates until the date of this release is enough too)[/li][/ul]
Installation instructions: https://github.com/S…3.5/INSTALL.md

DownloadFULL” version: http://community.trinitycore.org/files/file/22-trinitycore-json-api-full/

Alternative download: https://github.com/ShinDarth/TC-JSON-API/releases/download/v0.5/FULL.TrinityCore.JSON.REST.API.0.5.zip

Hello,

I’m having a bit of trouble trying to get past this error “[COLOR=rgb(235,235,235)]ERROR: API not found, please edit your config.js file and set the path of your TrinityCore JSON API istance.”

As you can see the permissions for the directories are as they should be.

/var/www/html/

drwxr-xr-x. 6 root root 4096 Sep 11 23:49 keira2
drwxr-xr-x. 11 root root 4096 Sep 11 23:00 TC-JSON-API
/var/www/html/keira2/

-rw-r–r–. 1 root root 147 Sep 12 00:01 config.js
drwxr-xr-x. 3 root root 4096 Jul 9 16:03 css
drwxr-xr-x. 2 root root 4096 Jul 9 16:03 fonts
-rw-r–r–. 1 root root 21 Jul 9 16:03 .gitignore
-rw-r–r–. 1 root root 4276 Jul 9 16:03 index.html
drwxr-xr-x. 4 root root 4096 Jul 9 16:03 js
-rw-r–r–. 1 root root 35142 Jul 9 16:03 LICENSE
drwxr-xr-x. 9 root root 4096 Jul 9 16:03 partials
-rw-r–r–. 1 root root 3600 Jul 9 16:03 README.md
/var/www/html/TC-JSON-API/public/

drwxr-xr-x. 2 root root 4096 Sep 11 22:55 css
-rw-r–r–. 1 root root 0 Sep 11 22:55 favicon.ico
drwxr-xr-x. 2 root root 4096 Sep 11 22:55 fonts
-rw-r–r–. 1 root root 142 Sep 11 22:55 .htaccess
-rw-r–r–. 1 644 root 1832 Sep 11 22:55 index.php
-rw-r–r–. 1 root root 24 Sep 11 22:55 robots.txt
This is what it looks like inside config.js

(function () {
var app = angular.module(‘keira2’);

/* Edit with path of TC-JSON-API */
app.api = “…/TC-JSON-API/public/index.php/”;

})();
If I copy this line: …/TC-JSON-API/public/ and close the file, and “cd” into it, I am in that directory. index.php resides there.

Any ideas why this error persists?

[ATTACH]1470._xfImport[/ATTACH]

@octaynIt seems you haven’t installed the API properly.

What happens if you try to load http://localhost/TC-JSON-API/public/index.php ?

If you get blank page, check inside /var/www/html/TC-JSON-API/storage/logs/ and check what errors you are getting, viewing the log files.

If you don’t get any logs, try to set 777 to all TC-JSO-API files and subfolders.

@Shin

After giving the entire folder and subfolders 777, there are still no logs stored in that folder.

You are correct about the white page.

I checked apache logs and this is the latest entry:

[Sat Sep 12 01:46:06 2015] [error] [client 192.80.186.134] PHP Warning: require(/var/www/html/TC-JSON-API/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/TC-JSON-API/bootstrap/autoload.php on line 17 [Sat Sep 12 01:46:06 2015] [error] [client 192.80.186.134] PHP Fatal error: require(): Failed opening required '/var/www/html/TC-JSON-API/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/TC-JSON-API/bootstrap/autoload.php on line 17

@Shin

After giving the entire folder and subfolders 777, there are still no logs stored in that folder.

You are correct about the white page.

I checked apache logs and this is the latest entry:

[Sat Sep 12 01:46:06 2015] [error] [client 192.80.186.134] PHP Warning: require(/var/www/html/TC-JSON-API/bootstrap/…/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/TC-JSON-API/bootstrap/autoload.php on line 17
[Sat Sep 12 01:46:06 2015] [error] [client 192.80.186.134] PHP Fatal error: require(): Failed opening required ‘/var/www/html/TC-JSON-API/bootstrap/…/vendor/autoload.php’ (include_path=‘.:/usr/share/pear:/usr/share/php’) in /var/www/html/TC-JSON-API/bootstrap/autoload.php on line 17

​Did you install the TC-JSON-API from sources or did you download the full version?

​The full version.

Edit: wait no I’m retarded. I downloaded the full version of keira - let me try that.

Result: Same thing - no logs, white page, Error no API found

New error though.

[Sat Sep 12 02:57:25 2015] [error] [client 75.137.245.22] PHP Parse error:  syntax error, unexpected '[' in /var/www/html/TC-JSON-API/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 49, referer:http://<MYIP>/keira2/

​Did you followed the installation instructions and installed all required software?

However, this is about the TC-JSON-API installation and is not strictly releated with Keira2, it would be better to move this discussion to Help & Support.

@octayn

Also, which version of PHP are you using?

the TC-JSON-API requires PHP 5.4 or newer

​Yep looks like it.

PHP 5.4.45 (cli) (built: Sep 5 2015 13:21:21)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

PHP 5.4.45 (cli) (built: Sep 5 2015 13:21:21)

​Can you try to update to PHP 5.5 or newer and see what happens?

I’m using PHP 5.5.9 and I can’t reproduce that error.