{% extends "master.html" %} {% block title %}API{% endblock %} {% block main %}

API Documentation

Using the API for this application is pretty simple. Just send a request to

http://sqlformat.appspot.com/format/

Options

The server accepts various options to control formatting. Only the data option is required. All others are optional.
Either use GET and pack the options in the query string or POST and submit your parameters as form data.
When using POST make sure your request includes a Content-Type: application/x-www-form-urlencoded header.

data
The SQL statement to format.
remove_comments
Set to 1 to remove comments.
keyword_case
How to convert keywords. Allowed values are 'lower', 'upper', 'capitalize'.
identifier_case
How to convert identifiers. Allowed values are 'lower', 'upper', 'capitalize'.
n_indents
An integer indicating the indendation depth.
right_margin
An integer indicating the maximum line length.
output_format
Transfer the statement into another programming language. Allowed values are 'python', 'php'

Example

Here's a example in Python:

{% include "python-client-example.html" %}

Download sqlformat_example_client.py

And another example using curl and a GET request:

$ curl "http://sqlformat.appspot.com/format?keyword_case=upper&reindent=true&data=select%20*%20from%20foo;"
SELECT *
FROM foo;
$
{% endblock %}