@ -37,3 +37,59 @@ Feel free to raise an issue on [github](https://github.com/mattgodbolt/compiler-
Compiler Explorer is maintained by [Matt Godbolt](http://xania.org). Multiple compiler and difference view was
implemented by [Gabriel Devillers](https://github.com/voxelf).
### RESTful API
There's a simple restful API that can be used to do compiles to asm and to list compilers. In general
all handlers live in `/api/*` endpoints, and will accept JSON or text in POSTs, and will return text responses
or JSON responses depending on the request's `Accept` header.
At a later date there may be some form of rate-limiting: currently requests will be queued and dealt with
exactly like interactive requests on the main site. Authentication might be required at some point in the
future (for the main Compiler Explorer site anyway).
The following endpoints are defined:
#### `GET /api/compilers` - return a list of compilers
Returns a list of compilers. In text form, there's a simple formatting of the ID of the compiler and its
description. In JSON, all the information is returned as an array of compilers, with the `id` key being the
primary identifier of each compiler.
#### `POST /api/<compiler-id>/compiler` - perform a compilation
To specify a compilation request as a JSON document, post it as the appropriate type and send an object of
the form: `{'source': 'source to compile', 'options': 'compiler flags', 'filters': {'filter': true}}`. The filters are an JSON object with true/false. If not supplied, defaults are used. If supplied, the filters are used
as-is.
A text compilation request has the source as the body of the post, and uses query parameters to pass the
options and filters. Filters are supplied as a comma-separated string. Use the query parameter `filters=XX`
to set the filters directly, else `addFilters=XX` to add a filter to defaults, or `removeFilters` to remove from defaults. Compiler parameters should be passed as `options=-O2` and default to empty.
Filters include `binary`, `labels`, `intel`, `comments` and `directives` and correspond to the UI buttons on
the HTML version.
The text request is designed for simplicity for command-line clients like `curl`: