Skip to content

Instantly share code, notes, and snippets.

@stevschmid
Created September 5, 2015 15:26
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevschmid/120adcbc5f1f7cb31bc5 to your computer and use it in GitHub Desktop.
Save stevschmid/120adcbc5f1f7cb31bc5 to your computer and use it in GitHub Desktop.
How the Track-o-Bot API works

Authentication

Access any profile page by providing the username and API key (generated in the settings -> API) , e.g. https://trackobot.com/profile/history.json?username=cool-ancient-tree-1337&token=fhyf238cv2eh879

JSON

Any profile page can be requested as JSON. Simply add .json at the end of the url (but before the query string which starts with ?), see example above.

Use the browser to see the JSON structure. JSONView is an excellent browser extension which shows JSON in a nice way.

POSTing

You can upload results with POSTing to /profile/results.json (don't forget to add the username and API key at the end).

The body of the POST should look like this:

{
   "result": {
     "hero": "Shaman",
     "opponent": "Warrior",
     "mode": "ranked",
     "coin": true,
     "win": true
   }
 }

You can include additional (optional) information, e.g.:

{
 "result": {
   "hero": "Shaman",
   "opponent": "Warrior",
   "mode": "ranked",
   "coin": true,
   "win": true,
   "duration": 634,
   "card_history": [
     {
       "card_id": "EX1_405",
       "player": "opponent"
     },
     {
       "card_id": "GAME_005",
       "player": "me",
       "turn": 3
     }
   ]
 }
}
@bl4ck0r
Copy link

bl4ck0r commented Nov 6, 2015

dont understand what i need to do that could you explane more detailed ?

@theanine
Copy link

It looks like the History page also has a timestamp, but I don't see that in the body of the POST above. Do you just use the timestamp of the POST?

@Mathieson
Copy link

Any way to POST decks? Looked at the json page for the decks and it doesn't show me the cards included in the deck, so I'm unsure what the format should be. This would be super handy.

@fverdoja
Copy link

fverdoja commented Feb 7, 2017

Is this documentation still actual? I'm trying to send request to profile/results.json and I get 404.

@justinpawela
Copy link

@fverdoja I just had success POSTing the following result to https://trackobot.com/profile/results.json after:

  1. Setting the HTTP Content-Type header to application/json
  2. Setting the HTTP Authorization header to Basic USERNAME:TOKEN
    • make sure to base64 encode the username:token portion as per the spec
{
  "result": {
    "hero": "Hunter",
    "opponent": "Warlock",
    "mode": "ranked",
    "rank": 17,
    "coin": true,
    "win": false,
    "added": "2017-02-12T17:52:35Z"
  },
  "username": "XXX",
  "token": "XXX"
}

I got back a 201 Created.

You'll note that I have the authorization included in both the headers and the JSON body. Looking through the source code, it appears that the headers are what the Track-o-Bot app uses, but i threw it into the body as well just because the doc above is pretty vague. Feel free to let us know if it works without them in the JSON body.

@xiaohk
Copy link

xiaohk commented Dec 19, 2018

@justinpawela I tried your method, but it didn't work (404) ☹️. Does it still work for you?

Never mind, it still works. Body username and token are necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment