Welcome to Diabolical!

Diabolical is a very simple web service backed by Google App Engine that simulates a hypothetical role-playing game. Services and sample code for using those services using jQuery are shown below.

Operation Method, URI, Sample Code

Get the current list of characters.

Error 404 if no characters are found.

GET http://lmu-diabolical.appspot.com/characters

$.getJSON(
    "http://lmu-diabolical.appspot.com/characters",
    function (characters) {
        // Do something with the character list.
        characters.forEach(function (character) {
            console.log(character);
        });
    }
);

Get the character with a particular ID.

Error 404 if there is no character with the given ID.

GET http://lmu-diabolical.appspot.com/characters/id

$.getJSON(
    "http://lmu-diabolical.appspot.com/characters/5629499534213120",
    function (character) {
        // Do something with the character.
        console.log(character);
    }
);

Save a new character to the system.

Status 201 CREATED is returned upon successful creation. The URL for the new character is returned in the Location header.

POST http://lmu-diabolical.appspot.com/characters

$.ajax({
    type: 'POST',
    url: "http://lmu-diabolical.appspot.com/characters",
    data: JSON.stringify({
        name: "Sam",
        classType: "rogue",
        gender: "MALE",
        level: 89,
        money: 4732349
    }),
    contentType: "application/json",
    dataType: "json",
    accept: "application/json",
    complete: function (jqXHR, textStatus) {
        // The new character can be accessed from the Location header.
        console.log("You may access the new character at:" +
            jqXHR.getResponseHeader("Location"));
    }
});

Update an existing character.

Error 400 if the ID in the URL and the payload character’s ID do not match. Response is status 204 NO CONTENT if successful.

PUT http://lmu-diabolical.appspot.com/characters/id

$.ajax({
    type: 'PUT',
    url: "http://lmu-diabolical.appspot.com/characters/5891733057437696",
    data: JSON.stringify({
        id: 5891733057437696,
        name: "Sam",
        classType: "rogue",
        gender: "MALE",
        level: 1,
        money: 0
    }),
    contentType: "application/json",
    dataType: "json",
    accept: "application/json",
    success: function (data, textStatus, jqXHR) {
        console.log("Done: no news is good news.");
    }
});

Delete an existing character.

Response is status 204 NO CONTENT if successful.

DELETE http://lmu-diabolical.appspot.com/characters/id

$.ajax({
    type: 'DELETE',
    url: "http://lmu-diabolical.appspot.com/characters/5891733057437696",
    success: function (data, textStatus, jqXHR) {
        console.log("Gone baby gone.");
    }
});

Create a random item.

GET http://lmu-diabolical.appspot.com/items/spawn with two parameters: level (an integer for the item’s base “level”) and slot (a string indicating what part of the character may use the item, e.g., “body” or “head”)

$.getJSON(
    "http://lmu-diabolical.appspot.com/items/spawn",
    {
        level: 50,
        slot: "body"
    },
    function (item) {
        // Mmmmm, new item.
        console.log(item);
    }
);

Create a random character (and we do mean random!).

GET http://lmu-diabolical.appspot.com/characters/spawn

$.getJSON(
    "http://lmu-diabolical.appspot.com/characters/spawn",
    function (character) {
        // Do something with the character.
        console.log(character);
    }
);

The code for this service can be found in our GitHub repository. The master branch shows the original stack; the gae branch shows what has been ported to GAE (this app!).

References