Planets.Nu API: Difference between revisions
HandsomeCam (talk | contribs) (Added API documentation stub) |
HandsomeCam (talk | contribs) (Added Login documentation) |
||
Line 3: | Line 3: | ||
The public API calls consist of: | The public API calls consist of: | ||
* 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 the games on the Planets Nu platform in various ways | * 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 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: | |||
{"success":false,"error":"This is the error message."} | |||
===Login=== | |||
The login API returns an API key which can be used along with a username for subsequent API calls. | |||
To use the login command HTTP GET to http://api.planets.nu/login 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 | |||
|- | |||
| username || account username | |||
|- | |||
| password || account password | |||
|} | |||
Example: | |||
<code>http:/<nowiki />/api.planets.nu/login?username=user12345&password=straightouttagalibor</code> | |||
The response is a JSON dictionary with the following keys: | |||
{| cellspacing="0" cellpadding="5" style="white-space:nowrap;" border="1" | |||
|-bgcolor=lightblue | |||
! align="left" | key | |||
! align="left" | 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: <code>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</code> where any <code>x</code> 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. | |||
==References== | ==References== | ||
[http://planets.nu/api-documentation Official API Documentation] | [http://planets.nu/api-documentation Official API Documentation] |
Revision as of 21:17, 20 November 2012
On December 21, 2011, Planets.Nu opened up an API for developers.
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."}
Login
The login API returns an API key which can be used along with a username for subsequent API calls.
To use the login command HTTP GET to http://api.planets.nu/login with the following values passed on the connection string:
variable | description |
---|---|
username | account username |
password | account password |
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.