Players are an integral entity within the API. Every resource that requires authentication (see Authentication) requires player credentials to make use of them, and several resources have more direct links to players (e.g. devgroups consist of lists of players).
Of particular note is the player token resources, which are useful for verifying that a player is who they say they are. A player client can request a new token and pass it to a service that needs to verify their identity (such as a game server), then said service can validate that token independently, confirming the player’s identity.
A game client can also use the myinfo resource to authenticate a player, as the API will only return a 200 status code if the provided credentials are correct.
There is currently no way to create a new player via the API, you have to register at http://kag2d.com/ in order to do that.
Player public info resource.
Example request:
GET /player/shadlington/info HTTP/1.1
Host: api.kag2d.com
Accept: application/json
Example response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"playerInfo": {
"active": true,
"banExpiration": null,
"banReason": null,
"banned": false,
"gold": true,
"gold_storm": true,
"gold_trenchrun": true,
"regUnixTime": 1386522342,
"registered": "2013-12-08 17:05:42",
"role": 1,
"username": "Shadlington"
}
}
Parameters: |
|
---|---|
Status Codes: |
|
Response JSON fields: | |
|
Player private info resource. Uses HTTP basic auth - the username in the authorization header must match the username in the URL.
Example requests:
GET /player/shadlington/myinfo HTTP/1.1
Host: api.kag2d.com
Accept: application/json
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Example response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"playerInfoPrivate": {
"active": true,
"banExpiration": null,
"banReason": null,
"banned": false,
"gold": true,
"gold_storm": true,
"gold_trenchrun": true,
"receiveEmails": true,
"regUnixTime": 1386522342,
"registered": "2013-12-08 17:05:42",
"role": 1,
"termsAccepted": true,
"username": "Shadlington"
}
}
Parameters: |
|
---|---|
Status Codes: |
|
Substatus 40301: | |
when the auth is correct but the player is inactive. |
|
Response JSON fields: | |
|
Player private info resource, used for authentication on the forums. Uses HTTP basic auth - the username in the authorization header must match the username in the URL.
Example requests:
GET /player/shadlington/foruminfo HTTP/1.1
Host: api.kag2d.com
Accept: application/json
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Example response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"playerInfoForum": {
"active": true,
"banExpiration": null,
"banReason": null,
"banned": false,
"email": "notarealemail@bluh.com",
"gold": true,
"gold_storm": true,
"gold_trenchrun": true,
"role": 1,
"userID": 9001,
"username": "Shadlington"
}
}
Parameters: |
|
---|---|
Status Codes: |
|
Substatus 40301: | |
when the auth is correct but the player is inactive. |
|
Response JSON fields: | |
|
Player status resource.
Example request:
GET /player/shadlington/status HTTP/1.1
Host: api.kag2d.com
Accept: application/json
Example response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"playerStatus": {
"action": 2,
"lastUpdate": "2013-12-08 17:05:49",
"server": {
"IPv4Address": "83.6.192.140",
"IPv6Address": null,
"port": 50301
}
}
}
Parameters: |
|
---|---|
Status Codes: |
|
Response JSON fields: | |
|
Player ban flags resource.
Example request:
GET /player/shadlington/banflags HTTP/1.1
Host: api.kag2d.com
Accept: application/json
Example response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"playerBanFlags": {
"all": [
"abuser",
"griefer"
],
"current": [
"abuser"
]
}
}
Parameters: |
|
---|---|
Status Codes: |
|
Response JSON fields: | |
|
Player status resource.
Example request:
GET /player/shadlington/status HTTP/1.1
Host: api.kag2d.com
Accept: application/json
Example response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"playerBanFlags": {
"all": [
"abuser",
"griefer"
],
"current": [
"abuser"
]
},
"playerInfo": {
"active": true,
"banExpiration": "2013-12-09 06:59:09",
"banReason": "Some reason or other",
"banned": true,
"gold": true,
"regUnixTime": 1386522342,
"registered": "2013-12-08 17:05:42",
"role": 1,
"username": "Shadlington"
},
"playerStatus": {
"action": 2,
"lastUpdate": "2013-12-08 17:05:49",
"server": {
"IPv4Address": "83.6.192.140",
"IPv6Address": null,
"port": 50301
}
}
}
Parameters: |
|
---|---|
Status Codes: |
|
Response JSON fields: | |
|
Player token generation resource. If the user provided in the URL is valid, generates a token for them. Tokens expire after a minute or when they are used, whichever comes first.
Example request:
GET /player/shadlington/token/new HTTP/1.1
Host: api.kag2d.com
Accept: application/json
Example response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"playerToken": "sometokenstring",
}
Parameters: |
|
---|---|
Status Codes: |
|
Substatus 40301: | |
when the auth is correct but the player is inactive. |
|
Response JSON fields: | |
|
Player token verification resource. Simply checks if the token provided in the URL is valid for this user.
Example request:
GET /player/shadlington/token/sometokenstring HTTP/1.1
Host: api.kag2d.com
Accept: application/json
Example responses:
HTTP/1.1 200 OK
Content-Type: application/json
{
"banned": false,
"playerTokenStatus": false,
"statusMessage": "Token not found"
}
HTTP/1.1 200 OK
Content-Type: application/json
{
"banned": false,
"playerTokenStatus": true,
"statusMessage": "Token found"
}
Parameters: |
|
---|---|
Status Codes: |
|
Response JSON fields: | |
|
Player avatar resource. Requests can either be made to /player/<username>/avatar or /player/<username>/avatar/<size> (where size is s, m or l). In either case the urls of the player avatars are provided - when a size is given, only the url for that size is returned, otherwise all sizes are returned.
Example requests:
GET /player/shadlington/avatar HTTP/1.1
Host: api.kag2d.com
Accept: application/json
GET /player/shadlington/avatar/s HTTP/1.1
Host: api.kag2d.com
Accept: application/json
Example responses:
HTTP/1.1 200 OK
Content-Type: application/json
{
"large": "https://forum.thd.vg/data/avatars/l/0/10.jpg",
"medium": "https://forum.thd.vg/data/avatars/m/0/10.jpg",
"small": "https://forum.thd.vg/data/avatars/s/0/10.jpg"
}
HTTP/1.1 200 OK
Content-Type: application/json
{
"small": "https://forum.thd.vg/data/avatars/s/0/10.jpg"
}
Parameters: |
|
---|---|
Status Codes: |
|
Response JSON fields: | |
|
Player term status update resource.
Example request:
PUT /player/shadlington/terms/status HTTP/1.1
Host: api.kag2d.com
Content-Type: application/json
{
"termsStatus":
{
"termsVersion": 999,
"termsHash": somehash,
"acceptance": 1
}
}
Example response:
HTTP/1.1 200 OK
Content-Type: application/json
{}
Parameters: |
|
---|---|
Status Codes: |
|
Substatus 40301: | |
when the auth is correct but the player is inactive. |
|
Request JSON fields: | |
|
Player receive emails status update resource.
Example request:
PUT /player/shadlington/receiveemails/status HTTP/1.1
Host: api.kag2d.com
Content-Type: application/json
{
"receiveEmails":
{
"status": 1
}
}
Example response:
HTTP/1.1 200 OK
Content-Type: application/json
{}
Parameters: |
|
---|---|
Status Codes: |
|
Substatus 40301: | |
when the auth is correct but the player is inactive. |
|
Request JSON fields: | |
|