summaryrefslogtreecommitdiff
path: root/extras/appengine/sqlformat/templates/api.html
blob: 2b32cbb34d8a7f9dc1ffd49d8917b3d672e49be5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{% 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 %}