API Documentation

Basics

Login or Register to see your User ID and API Key.

Login Register

Send your User ID, API Key, and any other paramters in a JSON POST request to the desired API path.

{
	"user_id": 1,
	"api_key": "3c2b3fec3de9939d6c111b5782a67992",
	"parameter": "value"
} 

The API returns JSON. Check success or error boolean in the response to verify if the call succeeded. When error is true, error_code and error_message will also be provided.

{
	"success": false,
	"error": true,
	"error_code": "game_bid_already_exists",
	"error_message": "You already have a bid for this game."
} 

Example

Create a bid of 50 on a game with an id of 3

URL

https://karmadilemma.com/api/game/bid

JSON POST Request

{
	"user_id": 1,
	"api_key": "3c2b3fec3de9939d6c111b5782a67992",
	"game_id": 3,
	"amount": 50
} 

Terminal

curl -H "Content-Type: application/json" -X POST -d '{"user_id":"1","api_key":"3c2b3fec3de9939d6c111b5782a67992","game_id":3,"amount":50}' https://karmadilemma.com/api/game/bid 

Javascript

// Create URL
$path = 'game/bid';
var url = 'https://karmadilemma.com/api/' + $path;

// Create JSON POST
var data = {};
data.user_id = 1;
data.api_key = '3c2b3fec3de9939d6c111b5782a67992';
data.game_id = 3;
data.amount = 50;

// Perform API Call
var xhr = new XMLHttpRequest();
xhr.open('POST', url, false);
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
xhr.send(JSON.stringify(data));

// Get Response
var response = JSON.parse(xhr.responseText);
if (response.error) {
	console.log(response.error_code + ' - ' + response.error_message);
}
console.log(response); 

PHP

// Create URL
$path = 'game/bid';
$url = 'https://karmadilemma.com/api/' . $path;

// Create JSON POST
$data = array();
$data['user_id'] = 1;
$data['api_key'] = '3c2b3fec3de9939d6c111b5782a67992';
$data['game_id'] = 3;
$data['amount'] = 50;
$post = json_encode($data);

// Perform API Call
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$raw_response = curl_exec($ch);

// Get Response
$response = json_decode($raw_response);
if ($response->error) {
    echo $response->error_code . ' - ' . $response->error_message;
}
var_dump($response); 

Paths

API Base URL

https://karmadilemma.com/api/

Get all games currently on auction

games_on_auction

Get your started games

started_games

Get your finished games

finished_games
  • @1 is the direct you want to sort. Value must be asc or desc.
  • @2 is the limit of results to get. Must be a positive integer. The maximum value is 100.
  • @3 is the offset. Must be a positive integer.
  • All these parameters are optional. By default it returns the 100 most recent games.

Get karma currently on auction

karma_on_auction

Create a bid for a game on auction

game/bid
  • Requires POST parameter game_id. Must be a positive integer.
  • Requires POST parameter amount. Must be between an integer -100 (Lowest Bid) and 100 (Highest Bid).

Play a game by sending your choice

game/play
  • Requires POST parameter game_id. Must be a positive integer.
  • Requires POST parameter choice. Must be either 0 (Do Nothing) or 1 (Take Action).
  • Will return the finished game if you are the second player to play.

Create a bid for a karma on auction

karma/bid
  • Requires POST parameter karma_id. Must be a positive integer.
  • Requires POST parameter amount. Must be between an integer 0 (Lowest Bid) and 100 (Highest Bid).

Give another user karma

karma/give
  • Requires POST parameter type. Must be either 0 (Bad Karma) or 1 (Good Karma).
  • Requires POST parameter other_player_user_id. Must be a positive integer.

Sell karma by putting it up on auction

karma/sell
  • Requires POST parameter type. Must be either 0 (Bad Karma) or 1 (Good Karma).

Get a game

single_game/@1
  • @1 is the game id. Must be a positive integer.

Get a karma

single_karma/@1
  • @1 is the karma id. Must be a positive integer.

Get a user

single_user/@1
  • @1 is the user id. Must be a positive integer.

Get your own user

my_user

Get the leaderboard

leaderboard/@1/@2/@3/@4
  • @1 is the column you want to sort by. Must be a valid column. Example: score
  • @2 is the direct you want to sort. Value must be asc or desc.
  • @3 is the limit of results to get. Must be a positive integer. The maximum value is 100.
  • @4 is the offset. Must be a positive integer.
  • All these parameters are optional. By default it returns top 100 score leaders.

Existing bots

If you have a bot for this game, send the GitHub link to goosepostbox@gmail.com and I'll feature it here.