Skip to content

Instantly share code, notes, and snippets.

@rymate1234
Last active December 18, 2019 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rymate1234/1061940923733a1152d2d43c32205f4f to your computer and use it in GitHub Desktop.
Save rymate1234/1061940923733a1152d2d43c32205f4f to your computer and use it in GitHub Desktop.
reverse engineering

Auth

-> % http POST https://api.aidungeon.io/users email=xxxx@xxxx.com password=xxxxx
HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Wed, 18 Dec 2019 09:03:49 GMT
ETag: W/"166-LlQXL0ICoRcyyTc4MbdOF/IuhQA"
Server: nginx/1.16.1
Transfer-Encoding: chunked
Vary: Origin, Accept-Encoding
X-Powered-By: Express

{
    "accessToken": "",
    "createdAt": "2019-12-16T15:07:03.000Z",
    "deletedAt": null,
    "email": "",
    "facebookAccessToken": null,
    "facebookAccountId": null,
    "id": 000,
    "isSetup": true,
    "password": "",
    "updatedAt": "2019-12-16T15:07:21.000Z",
    "username": "rymate1234"
}

Facebook auth --- too lazy to reverse engineer

Authed Routes

Take access token and pass as header X-Access-Token

Actually playing the game

Getting current available games

https://api.aidungeon.io/sessions/*/config

Returns data in a form similar to:

{
    "modes": {
        "apocalyptic": {
            "characters": {
                "courier": {
                    "items1": [
                        "parcel of letters"
                    ],
                    "items2": [
                        "small pistol"
                    ],
                    "prompts": [
                        "It's a long and dangerous road from Boston to Charleston, but you're one of the only people who knows the roads well enough to get your parcel of letters there. You set out in the morning and"                                                                                                     
                    ]
                },
                "scavenger": {
                    "items1": [
                        "rusty knife"
                    ],
                    "items2": [
                        "canteen"
                    ],
                    "prompts": [
                        "You walk for two hours and take a break. You've left your town in search of food. You look around and see"
                    ]
                },
                "soldier": {
                    "items1": [
                        "automatic rifle"
                    ],
                    "items2": [
                        "grenade"
                    ],
                    "prompts": [
                        "You have lived in this military bunker since the bombs went off. You wake up and report for duty to your commanding officer and"
                    ]
                },
                "survivor": {
                    "items1": [
                        "hatchet"
                    ],
                    "items2": [
                        "hunting rifle"
                    ],
                    "prompts": [
                        "You live in a small community of survivors who have managed to build a piece of civilization after the bombs fell. You are talking to one of the leaders of the community when"                                                                                                                      
                    ]
                }
            },
            "settings": [
                "trying to survive in a post apocalyptic world by scavenging among the ruins of what is left."
            ]
        }
    ]
}

Mode keys are a storyMode and character keys are the charcterType

Creating a session

path: '/sessions',
data: {
    storyMode: o, 
    characterType: n,
    name: u,
    customPrompt: c
}

Sample Requests

$ http POST https://api.aidungeon.io/sessions X-Access-Token:xxxxxxx customPrompt="You are a programmer procrastinating in a seminar."
HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Wed, 18 Dec 2019 11:14:41 GMT
ETag: W/"1a0-xJy7iq6YGQXn3YhCJYIxPpDCrNQ"
Server: nginx/1.16.1
Transfer-Encoding: chunked
Vary: Origin, Accept-Encoding
X-Powered-By: Express

{
    "createdAt": "2019-12-18T11:14:41.894Z",
    "id": xxxxx,
    "story": [
        {
            "type": "output",
            "value": "You are a programmer procrastinating in a seminar. You have been working on a program that will allow you to communicate with other computers, but it is not yet complete and you need your computer science class to see if it is ready for release."
        }
    ],
    "storyPublicId": "xxxxx",
    "updatedAt": "2019-12-18T11:14:41.896Z",
    "userId": xxxxx
}

% http POST https://api.aidungeon.io/sessions X-Access-Token:xxxxx storyMode=apocalyptic characterType=courier name=rymate1234
HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Wed, 18 Dec 2019 23:40:11 GMT
ETag: W/"249-RdamQp9RDd9ozI0nbQ8LUTCToQA"
Server: nginx/1.16.1
Transfer-Encoding: chunked
Vary: Origin, Accept-Encoding
X-Powered-By: Express

{
    "createdAt": "2019-12-18T23:40:11.500Z",
    "id": xxxx,
    "story": [
        {
            "type": "output",
            "value": "You are rymate1234, a courier trying to survive in a post apocalyptic world by scavenging among the ruins of what is left. You have a parcel of letters and a small pistol. It's a long and dangerous road from Boston to Charleston, but you're one of the only people who knows the roads well enough to get your parcel of letters there. You set out in the morning and hope that you'll reach Charleston before nightfall."
        }
    ],
    "storyPublicId": "xxx",
    "updatedAt": "2019-12-18T23:40:11.503Z",
    "userId": xxxx
}

Continuing a game

path: "/sessions/" + n + "/inputs",
data: {
    text: u
}

Bonus Routes

GET /sessions

Returns all sessions you've ever done

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