Skip to content
Ryan Mark edited this page Jan 19, 2016 · 22 revisions

Autotune has a Web API built for the front-end javascript app. It can be used by other applications to do anything you're able to do with the Web UI.

Intro

The API endpoints exactly map to the application URLs you see when navigating the application. The API is entirely JSON-based. All data is returned as JSON, all request data must be JSON-formatted.

All requests must set the Accept header:

Accept: application/json

All POST, PUT, PATCH requests must set the Content-Type header:

Content-Type: application/json

Authentication

Autotune requires a simple bearer token in your HTTP headers for API access:

Authorization: API-KEY auth=ABC123

You can create a machine account for accessing the API with the create_superuser rake task:

$ rake create_superuser[[email protected]]

You can grab the API key of an existing user with the get_api_key rake task:

$ rake get_api_key[[email protected]]

In production, API requests must go over HTTPS. The API is not designed to be secure over unencrypted connections.

Errors

The API will emit appropriate HTTP status codes if there are errors: 4xx errors if the problem is with the request, 500 if there is an error on the server, 2xx for success.

Errors that result from a bad request (4xx) will include a JSON payload with an errors attribute:

{ "error": "Some message" }

These error messages are intended to be presented directly to the user.

Projects

List GET /projects

Return a list of projects, sorted reverse chronologically by last update time.

API query options (all are optional)

/projects
  ?page=1            # return x page of results
  &per_page=15       # return x number of results per page
  &theme=abc123      # return projects that are using this theme name (slug of theme)
  &blueprint_title=1 # return projects that are using this blueprint (ID of blueprint)
  &pub_status=draft  # return only draft or only published projects (draft or published)
  &search=foo        # return projects with names and/or authors matching this string

Response format

The JSON payload of the response is an array of objects. Each object has the following attributes:

status            # Project status: new, built, building, updating, broken
id                # ID of this project
slug              # Slug of this project
title             # Title of this project
preview_url       # Base URL to where the project is published
publish_url       # Base URL where the preview lives
type              # Type of project: graphic or app
blueprint_id      # ID of the blueprint used by this project
blueprint_title   # Full title of the blueprint used by this project
blueprint_version # Version of the blueprint that project is locked to
theme             # Slug of the theme
created_by        # Full name of the user who created this
user_id           # ID of the user who created this
created_at        # When this project was created
updated_at        # When this project was last changed
published_at      # When this project was published
data_updated_at   # When the form data in this project was last changed

Get GET /projects/<id_or_slug>

Return a project.

Blueprints

TK