Planets.Nu API: Difference between revisions
HandsomeCam (talk | contribs) m (→Public API: Linked to actual List Games definition) |
HandsomeCam (talk | contribs) (Added Load Game Info API call, restructured the page) |
||
Line 1: | Line 1: | ||
On December 21, 2011, [[VGA_Planets_Nu|Planets.Nu]] opened up an API for developers. | On December 21, 2011, [[VGA_Planets_Nu|Planets.Nu]] opened up an API for developers. | ||
=Public API= | |||
The public API calls consist of: | The public API calls consist of: | ||
Line 7: | Line 7: | ||
* [[#Login|Login]] - Use this to acquire the apikey of a given player. | * [[#Login|Login]] - Use this to acquire the apikey of a given player. | ||
* [[#List Games|List Games]] - List the games on the Planets Nu platform in various ways | * [[#List Games|List Games]] - List the games on the Planets Nu platform in various ways | ||
* Load Game Info - Load the publicly available data about a single game | * [[#Load Game Info|Load Game Info]] - Load the publicly available data about a single game | ||
* Load Turn Data - Load a single players complete turn package | * Load Turn Data - Load a single players complete turn package | ||
==Errors== | |||
API calls return a JSON dictionary. In the event of an API call failure, the following dictionary will be returned: | API calls return a JSON dictionary. In the event of an API call failure, the following dictionary will be returned: | ||
Line 16: | Line 16: | ||
{"success":false,"error":"This is the error message."} | {"success":false,"error":"This is the error message."} | ||
on occasion, instead of a JSON dictionary the following text is returned: | |||
Error: <i>Error Description Here</i> | |||
==Login== | |||
The login API returns an API key which can be used along with a username for subsequent API calls. | The login API returns an API key which can be used along with a username for subsequent API calls. | ||
Line 54: | Line 58: | ||
The API key is used for subsequent API calls for the given account. This is the API Key of the account and will only change if the user changes their account password. | The API key is used for subsequent API calls for the given account. This is the API Key of the account and will only change if the user changes their account password. | ||
==List Games== | |||
The list games API can return detailed information about all games on the Planets Nu website or for an individual player. This API is a public API and does not require authentication. | The list games API can return detailed information about all games on the Planets Nu website or for an individual player. This API is a public API and does not require authentication. | ||
Line 82: | Line 86: | ||
|} | |} | ||
Each game record will be returned in a JSON array of game objects: | Each game record will be returned in a JSON array of [[#Game Object|game objects]]: | ||
<code>[{game 1},{game 2},{game 3}]</code> | <code>[{game 1},{game 2},{game 3}]</code> | ||
====Game Object==== | ==Load Game Info== | ||
The Load Game Info API returns all the publicly available information about a game including its historical game records. | |||
The load game info command is a GET call to http://api.planets.nu/game/loadinfo with the following values passed on the connection string: | |||
{| cellspacing="0" cellpadding="5" style="white-space:nowrap;" border="1" | |||
|-bgcolor=lightblue | |||
! align="left" | variable | |||
! align="left" | description | |||
! align="left" | Required | |||
! align="center" | Default Value | |||
|- | |||
| gameid || The of the game being loaded || YES || n/a | |||
|} | |||
On success, the following JSON dictionary is returned: | |||
{| cellspacing="0" cellpadding="5" style="white-space:nowrap;" border="1" | |||
|-bgcolor=lightblue | |||
! align="left" | key | |||
! align="left" | value | |||
|- | |||
| game || A [[#Game Object|game object]] dictionary | |||
|- | |||
| players || An array of [[#Player Object|player object]] dictionaries | |||
|- | |||
| relations || An array of [[#Relation Object|relation object]] dictionaries | |||
|- | |||
| schedule || A text description of the host schedule | |||
|- | |||
| settings || A [[#Game Settings Object|game settings object]] dictionary | |||
|- | |||
| timetohost || A text description of the time until the next scheduled host | |||
|- | |||
| wincondition || A text description of the condition required to win the game | |||
|- | |||
| yearfrom || The Planets.NU year that the game began | |||
|- | |||
| yearto || The Planets.NU year the game ended | |||
|} | |||
=Common Data Objects= | |||
The following objects are used or returned by the API calls: | |||
==Game Object== | |||
The game object returned by List Games is a dictionary with the following keys: | The game object returned by List Games or Load Game Info is a dictionary with the following keys: | ||
{| cellspacing="0" cellpadding="5" style="white-space:nowrap;" border="1" | {| cellspacing="0" cellpadding="5" style="white-space:nowrap;" border="1" | ||
Line 166: | Line 216: | ||
|} | |} | ||
=References= | |||
[http://planets.nu/api-documentation Official API Documentation] | [http://planets.nu/api-documentation Official API Documentation] |
Revision as of 23:24, 20 November 2012
On December 21, 2011, Planets.Nu opened up an API for developers.
Public API
The public API calls consist of:
- Login - Use this to acquire the apikey of a given player.
- List Games - List the games on the Planets Nu platform in various ways
- Load Game Info - Load the publicly available data about a single game
- Load Turn Data - Load a single players complete turn package
Errors
API calls return a JSON dictionary. In the event of an API call failure, the following dictionary will be returned:
{"success":false,"error":"This is the error message."}
on occasion, instead of a JSON dictionary the following text is returned:
Error: Error Description Here
Login
The login API returns an API key which can be used along with a username for subsequent API calls.
The login command is an HTTP GET to http://api.planets.nu/login with the following values passed on the connection string:
variable | description | Required | Default Value |
---|---|---|---|
username | account username | YES | n/a |
password | account password | YES | n/a |
Example:
http://api.planets.nu/login?username=user12345&password=straightouttagalibor
The response is a JSON dictionary with the following keys:
key | value |
---|---|
success | Indicates if the call was successful (true or false) |
apikey | The API key used in other requests. An API key is formatted as: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx where any x is a hexadecimal value.
|
settings | The user's general settings as a dictionary |
The API key is used for subsequent API calls for the given account. This is the API Key of the account and will only change if the user changes their account password.
List Games
The list games API can return detailed information about all games on the Planets Nu website or for an individual player. This API is a public API and does not require authentication.
The list games command is a GET call to http://api.planets.nu/games/list
The following variables are all optional:
variable | description | Required | Default Value |
---|---|---|---|
status | Current status of games to return, with multiple values joined by commas. Possible values are: 1 : Joining 2 : Running 3 : Finished 4 : Hold |
NO | 1,2 |
type | The type of games to return, with multiple values joined by commas. Possible values are: 1 : Training 2 : Standard 3 : Team 4 : Melee 5 : Blitz |
NO | 2,3,4 |
scope | Current scope of games to return, with multiple values joined by commas. Possible values are: 0 : Public 1 : Custom (private games) |
NO | 0 |
ids | IDs of games to return, comma separated | NO | n/a |
username | Username of the account to list games. Will list all games for this user regardless of other settings | NO | n/a |
limit | The maximum number of records to return. A value of 0 (zero) will return all records. | NO | 0 |
Each game record will be returned in a JSON array of game objects:
[{game 1},{game 2},{game 3}]
Load Game Info
The Load Game Info API returns all the publicly available information about a game including its historical game records.
The load game info command is a GET call to http://api.planets.nu/game/loadinfo with the following values passed on the connection string:
variable | description | Required | Default Value |
---|---|---|---|
gameid | The of the game being loaded | YES | n/a |
On success, the following JSON dictionary is returned:
key | value |
---|---|
game | A game object dictionary |
players | An array of player object dictionaries |
relations | An array of relation object dictionaries |
schedule | A text description of the host schedule |
settings | A game settings object dictionary |
timetohost | A text description of the time until the next scheduled host |
wincondition | A text description of the condition required to win the game |
yearfrom | The Planets.NU year that the game began |
yearto | The Planets.NU year the game ended |
Common Data Objects
The following objects are used or returned by the API calls:
Game Object
The game object returned by List Games or Load Game Info is a dictionary with the following keys:
key | value |
---|---|
allturnsin | Indicates if all turns have been submitted |
createdby | |
datecreated | The date the game was created |
dateended | The date the game ended |
deletedate | The date the game was deleted |
description | The text description of the game |
difficulty | |
faststart | |
gametype | |
hostdays | The days of the week the host will run in the format SMTWTFS. An underscore will replace days the host will not run. eg. _M___F_ indicates the host will run on mondays and fridays |
hosttime | The scheduled time of day for the host to run on scheduled host days |
id | The ID of the game |
ishosting | |
isprivate | |
lastbackuppath | |
lastloadeddate | |
lastnotified | |
maptype | |
masterplanetid | |
maxlevelid | The maximum level for captains to participate in the game |
name | The name of the game / system |
nexthost | The datetime of the next scheduled host run |
quadrant | |
requiredlevelid | The required level for captains to participate in the game |
scenarioid | |
shortdescription | |
slots | The number of player slots available in the game |
slowhostdays | |
status | |
turn | The current game turn |
turnsperweek | The number of scheduled turns per week |
turnstatus | A set of characters indicating which players have submitted their turns. An underscore indicates the turn is not yet viewed. |
tutorialid | |
wincondition | |
yearstarted |