Skip to content
Jeffrey Tong edited this page Aug 28, 2014 · 9 revisions

The HearthStats API

Response

{
"status":"success",
"data":{
        "complete":false,"created_at":"2014-01-25T19:15:53Z",
        "dust":0,
        "gold":0,
        "id":1833,
        "notes":null,
        "patch":"current",
        "updated_at":"2014-01-25T19:15:53Z",
        "user_id":1,
        "userclass":"Rogue"
       }
}

Matches

Match Entry

curl -X POST -H "Content-Type: application/json" -d '{"slot":1,"class": "Mage", "oppclass": "Druid","result": "Draw" ,"coin":"false", "rank":1, "mode": "Casual", "oppname":"MubaMu22ba"}' localhost:3000/api/v1/matches/new?userkey=secret

Parameters

  • userkey - required
  • mode - Accepts Arena, Casual, and Ranked
  • class - The player's class (e.g. "Mage", "Hunter", etc.)
  • oppclass - The opponent's class (e.g. "Mage", "Hunter", etc.)
  • result - The result of the match - accepts Win, Loss, Draw
  • coin - Whether or not the user had the coin - accepts true, false
  • numturns - The number of turns the user had in the match
  • duration - The duration of the match in seconds
  • notes - Any notes to add to the match
  • slot - The deck slot number from 1 to 9 - required when mode is Casual or Ranked
  • ranklvl - If mode is Ranked this will set the exact rank level - accepts 1 to 25

Arena

Last Arena Run

http://localhost:3000/api/v1/arena_runs/show?userkey=secret

Start Arena Run

curl -X POST -H "Content-Type: application/json" -d '{ "klass_id": 2 }' 
localhost:3000/api/v1/arena_runs/new?userkey=secret

End Arena Run

Use matches method above with mode set to Arena

Arena Entry

curl -X POST -H "Content-Type: application/json" -d '{"class": "Mage", "oppclass": "Druid","result": "Draw" ,"coin":"false", "rank":1, "mode": "Casual", "oppname":"MubaMu22ba", "notes":"Schooling"}'
localhost:3000/api/v1/matches/new?userkey=sercret

Constructed

Constructed Entry

Use matches method above with mode set to Casual or Ranked

Deck

Activate/Deactivate Deck

curl -X POST -H "Content-Type: application/json" -d '{"deck_id": 1652}' 
http://localhost:3000/api/v1/decks/activate?userkey=secret

Note that the deck id must belong to the user or an error will occur

Show All Decks

http://localhost:3000/api/v1/decks/show?userkey=secret

Delete Deck(s)

curl -X POST -H "Content-Type: application/json" -d '{"deck_id": [ids]}' 
http://localhost:3000/api/v1/decks/delete?userkey=secret

Note that the deck ids MUST be an array doesn't matter if it's one id or more than one. Also the decks must belong to the user with the userkey

Create Deck

curl -X POST -H "Content-Type: application/json" -d '{"deck": {"klass_id": 1, "name": "pro2"}, "deck_text": "2 Savannah Highmane\r\n2 Hunter\u0027s Mark\r\n2 Freezing Trap\r\n1 Tracking\r\n2 Houndmaster\r\n1 Explosive Trap\r\n2 Eaglehorn Bow\r\n2 Loot Hoarder\r\n2 Kill Command\r\n2 Leper Gnome\r\n2 Animal Companion\r\n2 Flare\r\n2 Undertaker\r\n2 Webspinner\r\n2 Mad Scientist\r\n2 Haunted Creeper"}' http://localhost:3000/api/v1/decks/create?userkey=secret

This looks very messy but that's due to all the new lines. The basic structure for creating a new deck looks likes this:

{
  "deck": { "klass_id": id, "name": name, "notes": notes },
  "deck_text": deck_string
}

Deck string should be in the Cockatrice format WITH the new lines and special characters MUST be replaced (see: http://www.utf8-chartable.de/ for utf8 codes).

Cards

Show All Cards

curl http://localhost:3000/api/v1/cards/

Show Specific Card

curl http://localhost:3000/api/v1/cards/:id
Clone this wiki locally