Application programming interface (API)

This API allows you to directly return all the data about the games listed on this site as well as searching the games by all the categories available whilst using this site.
The API currently only supports XML and JSON. And currently DOESN'T require you to get an API key, but this may be implemented in the future.
You may use the API and data however you like in any application but we would appreciate a link back to the site if you do use our API and a post about your project in the forum would be nice too. We also give all developers administration to the site and expect them to help maintain the database.

The API consists of 3 different files: Search.php, GetGame.php and GetCategories.php. All them require you to specify the return data type (either 'XML' or 'JSON' using the ContentType GET variable.

Also the API is open source and any contributes to it will be pushed to the live website. Find and contibute to the code here: github.com/thomaspreece10/TFGdb.com-API

GetCategories.php

This file gets details about the numerical values for various categories. This is useful as the various GET variable filters for Search.php only take numbers and not the string values. If you are still a bit confused see the example below

GET variable name Description Required?
ContentType Either 'XML' or 'JSON' depending on your requirements Yes

Example
http://tfgdb.com/API/GetCategories.php?ContentType=JSON
Returns JSON with all the numerical values for various categories including modes, genres, platforms, sources, graphics, studios, types and releases. So for example using this we could find out that the 'Freeware' type has id 1, we could then filter our search results in Search.php to only show games with type 'Freeware' by setting the GET variable 'Type' equal to 1. In other words our API request would be: 'Search.php?Type=1&ContentType=JSON'


Search.php

This file gets a list of games matching certain specified criteria.

GET variable name Description Required?
ContentType Either 'XML' or 'JSON' depending on your requirements Yes
Search Can specify Search or Letter but not both!
When specified only results with specified string in game 'Name' will be returned.
No
Letter Can specify Search or Letter but not both!
When specified only results with specified letter at start of game 'Name' will be returned.
No
Mode Integer value.
You can specify multiple values by adding together valid values. So for example 4+2=6 so setting a 'Mode' of 6 will filter games that are either 'Single Player' (2) or 'Multi Player' (4)
To see valid values see GetCategories.php above.
No
Gen Integer value.
You can specify multiple values by adding together valid values. So for example 4+32=36 so setting a 'Gen' of 36 will filter games that are either 'Arcade' (4) or 'Card Games' (32)
To see valid values see GetCategories.php above.
No
Plat Integer value.
You can specify multiple values by adding together valid values. So for example 16+1024+2048=3088 so setting a 'Plat' of 3088 will filter games that are either 'ScummVM' (16) or 'Desura-Mac' (1024) or 'Desura-Linux' (2048)
To see valid values see GetCategories.php above.
No
Release Integer value.
To see valid values see GetCategories.php above.
No
Graphics Integer value.
To see valid values see GetCategories.php above.
No
Type Integer value.
To see valid values see GetCategories.php above.
No
Source Integer value.
To see valid values see GetCategories.php above.
No
Studio Integer value.
To see valid values see GetCategories.php above.
No
Sort Integer value.
To see valid values see GetCategories.php above.
No

Example
http://tfgdb.com/API/Search.php?ContentType=XML&Search=battle&Gen=4&Studio=4
This searches for games with genre 4 (Arcade) and studio 4 (indie) and who have project in their name.


GetGame.php

This file gets all the details of a particular game. The requested game is identified by the unique ID it has in the database which you provide via the ID GET variable

GET variable name Description Required?
ContentType Either 'XML' or 'JSON' depending on your requirements Yes
ID The unique ID for the game you want to get the data for. Search.php provides an ID when it returns games, use that here to get more information about each game. Yes

Example
http://tfgdb.com/API/GetGame.php?ContentType=XML&ID=632
Returns the game information for 0 A.D.