Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/statico/ifhttp

👾 HTTP REST server for Z-Machine interactive fiction
https://github.com/statico/ifhttp

docker http http-server if inform inform7 interactive-fiction rest z-machine z8

Last synced: 2 months ago
JSON representation

👾 HTTP REST server for Z-Machine interactive fiction

Awesome Lists containing this project

README

        

# ifhttp

[![license](https://img.shields.io/github/license/statico/ifhttp.svg?style=flat-square)](https://github.com/statico/ifhttp/blob/master/LICENSE)
[![build status](https://img.shields.io/github/actions/workflow/status/statico/ifhttp/build.yml?branch=main&style=flat-square)](https://ghcr.io/statico/ifhttp)

**ifhttp** provides an HTTP REST interface for interacting with Z-Machine interactive fiction (IF) stories (typically `.z8` files). Clients can connect to the service to start a game and then POST commands to it. Sessions are deleted after a while in a feeble attempt to save memory. This service is definitely DoS-able.

**See a live example on https://www.langworth.com/**

## Usage

$ docker pull ghcr.io/statico/ifhttp
$ docker run -p 8080:8080 -v /path/to/stories:/data ghcr.io/statico/ifhttp npm run -s start -- /data/story.z8

## API

All request and response bodies should be JSON. In addition to a status code, requests may return a JSON object with an `error` property which describes the error.

### GET /new

Returns a session ID for a new game.

Response:

```json
{
"session": "",
"output": ""
}
```

### POST /send

Sends a command to the game.

Request:

```json
{
"session": "",
"message": ""
}
```

Response:

```json
{
"output": ""
}
```

## Reference

- [Inform](http://inform7.com/) - IF creation toolsuite
- [ifvms](https://github.com/curiousdannii/ifvms.js) - JavaScript Z-Machine VM used by this script
- [ifplayer](https://github.com/jedi4ever/ifplayer.js) - Command-line client which uses ifvms