{% extends "master.html" %}

{% block title %}API{% endblock %}

{% block main %}
<h1>API Documentation</h1>

<p>
  Using the API for this application is pretty simple. Just send a
  request to
</p>
<p>
  <code>http://sqlformat.appspot.com/format/</code>
</p>

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

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

<h2>Example</h2>
<p>
  Here's a example in Python:
</p>
{% include "python-client-example.html" %}
<p>
  <a href="/static/sqlformat_client_example.py">Download sqlformat_example_client.py</a>
</p>

<p>
  And another example using curl and a <code>GET</code> request:
</p>
<div class="highlight example"><pre>
$ curl "http://sqlformat.appspot.com/format<b>?</b>keyword_case=upper<b>&</b>reindent=true<b>&</b>data=select%20*%20from%20foo;"
SELECT *
FROM foo;
$
</pre></div>


{% endblock %}
