|
| 1 | +# TTDS API |
| 2 | + |
| 3 | +Shapes, colors, and so forth. |
| 4 | + |
| 5 | +## General API Structure |
| 6 | + |
| 7 | +Most interactions with the server begin with a request like this: |
| 8 | + |
| 9 | +``` |
| 10 | +POST /pane/<name>/create?color=%23XXXXXX |
| 11 | +``` |
| 12 | + |
| 13 | +Here, you specify two things. First, the pane needs a unique name, which should |
| 14 | +ideally be something human-readable, but need not be. Then, you specify the |
| 15 | +color. (Note that `%23` is the URL-escaped version of the `#` glyph, so what |
| 16 | +you're really doing here is specifying for a hex color preceded by a `#`.) E.g., |
| 17 | + |
| 18 | +``` |
| 19 | +POST /pane/example/create?color=%23000000 |
| 20 | +``` |
| 21 | + |
| 22 | +creates a pane named "example" with a solid black background color. On success, |
| 23 | +this will return a 200 and give you a UUID. Subsequent requests to the pane must |
| 24 | +include this UUID in the HTTP headers so as to prevent accidental requests |
| 25 | +overwriting a pane it shouldn't. So, for instance, to draw a rectangle, see for |
| 26 | +example |
| 27 | + |
| 28 | +``` |
| 29 | +POST /pane/example/rect?color=%23000000&x=0&y=0&h=100&w=100 |
| 30 | +Auth: db0b4cf0-e0a9-49c5-918a-52c13acbcbd7 |
| 31 | +``` |
| 32 | + |
| 33 | +Be sure to provide all of `x`, `y`, `w`, `h`, and a `color` along with an `Auth` |
| 34 | +header supplying that UUID you've got. See [below](#reference) for a list of all |
| 35 | +allowed methods. When done with a pane, it can be deleted with the same `Auth` |
| 36 | +header attached to a `DELETE` request: |
| 37 | + |
| 38 | +``` |
| 39 | +DELETE /pane/example/rect |
| 40 | +Auth: db0b4cf0-e0a9-49c5-918a-52c13acbcbd7 |
| 41 | +``` |
| 42 | + |
| 43 | +## Reference |
| 44 | + |
| 45 | +The following methods are allowed: |
| 46 | + |
| 47 | +| Method | Path | Query Parameters | Auth Required? | Description | |
| 48 | +|--------|--------------------------|--------------------------------|----------------|-------------------------------------| |
| 49 | +| POST | /pane/\<name\> | `color` | No. | Create a pane with the given color. | |
| 50 | +| POST | /pane/\<name\>/rect | `color`, `x`, `y`, `w`, `h` | Yes. | Draw a rectangle on a pane. | |
| 51 | +| POST | /pane/\<name\>/circle | `color`, `x`, `y`, `r` | Yes. | Draw a circle on a pane. | |
| 52 | +| POST | /pane/\<name\>/line | `color`, `x`, `y`, `x2`, `y2` | Yes. | Draw a line on a pane. | |
| 53 | +| POST | /pane/\<name\>/copy_rect | `x`, `y`, `w`, `h`, `x2`, `y2` | Yes. | Copy a rectangle to another place. | |
| 54 | +| DELETE | /pane/\<name\> | None. | Yes. | Delete a pane. | |
| 55 | + |
| 56 | + |
| 57 | +### Types |
| 58 | + |
| 59 | +Where `x`, `y`, `w`, and `h` (or `x2`, `y2`, and so forth) are given as query |
| 60 | +parameters, integer values are expected. `x = 0` and `y = 0` refers to the top |
| 61 | +left corner of the pane. |
| 62 | + |
| 63 | +Where `color` is a query parameter, the value expected should be of the form |
| 64 | +`%23XXXXXX`, where `%23` is the URL-escaped version of `#`, and `XXXXXX` is a |
| 65 | +hexadecimal color code. That is, ttds expects a URL-escaped color hex code. |
0 commit comments