| 1 | {extends "idf/base-simple.html"}␊ |
| 2 | {block docclass}yui-t3{/block}␊ |
| 3 | {block body}␊ |
| 4 | <p>At the moment, this documentation is only available in English.</p>␊ |
| 5 | ␊ |
| 6 | <ul>␊ |
| 7 | <li><a href="#q-overview">How to access the API?</a></li>␊ |
| 8 | <li><a href="#q-authentication">How to authenticate the queries?</a></li>␊ |
| 9 | </ul>␊ |
| 10 | ␊ |
| 11 | <h2 id="q-overview">How to access the API?</h2>␊ |
| 12 | ␊ |
| 13 | <p>␊ |
| 14 | The API is a REST API and you can access it by using the same URL you␊ |
| 15 | are using for the web interface but with the <code>/api/</code>␊ |
| 16 | prefix.␊ |
| 17 | </p>␊ |
| 18 | <p>␊ |
| 19 | For example, if you access a project with the␊ |
| 20 | URL <code>http://www.example.com/p/myproject/</code>, you have the␊ |
| 21 | following API URLs available:␊ |
| 22 | </p>␊ |
| 23 | <ul>␊ |
| 24 | <li><code>http://www.example.com/api/p/myproject/issues/</code>: list the open issues.</li>␊ |
| 25 | <li><code>http://www.example.com/api/p/myproject/issues/create/</code>: create a new issue.</li>␊ |
| 26 | </ul>␊ |
| 27 | <p>␊ |
| 28 | The answer you get is JSON and UTF-8 encoded. ␊ |
| 29 | </p>␊ |
| 30 | ␊ |
| 31 | ␊ |
| 32 | <h2 id="q-authentication">How to authenticate the queries?</h2>␊ |
| 33 | ␊ |
| 34 | <p>␊ |
| 35 | Authentication is really simple and is optional. If you do not␊ |
| 36 | authenticate your queries, you will have the same rights as an␊ |
| 37 | anonymous user visiting the normal web interface.␊ |
| 38 | </p>␊ |
| 39 | <p>␊ |
| 40 | To authenticate your query, you need to provide 3 parameters to your␊ |
| 41 | requests, the parameters are the followings:␊ |
| 42 | </p>␊ |
| 43 | <ul>␊ |
| 44 | <li><code>_login</code>: your login.</li>␊ |
| 45 | <li><code>_salt</code>: a random salt string.</li>␊ |
| 46 | <li><code>_hash</code>: the sha1 hash created from the concatenation of the random salt string and the API key.</li>␊ |
| 47 | </ul>␊ |
| 48 | <p>␊ |
| 49 | Please note that the 3 parameters are all starting with the underscore␊ |
| 50 | "_" character. ␊ |
| 51 | </p> ␊ |
| 52 | <p>␊ |
| 53 | An example of PHP code to generate the <code>_hash</code> value is:␊ |
| 54 | </p>␊ |
| 55 | <pre>␊ |
| 56 | <?php ␊ |
| 57 | $api_key = '1234567890abcdefghijklmnopqrstuvwxyz';␊ |
| 58 | $_salt = rand(10000, 999999);␊ |
| 59 | $_hash = sha1($_salt.$api_key);␊ |
| 60 | echo sprintf("_salt: %s\n", $_salt);␊ |
| 61 | echo sprintf("_hash: %s\n", $_hash);␊ |
| 62 | ?>␊ |
| 63 | </pre>␊ |
| 64 | <p>␊ |
| 65 | If you replace the string '123...xyz' with your own API key and␊ |
| 66 | execute this script, you will have as output something like that:␊ |
| 67 | </p>␊ |
| 68 | <pre>␊ |
| 69 | _salt: 123456␊ |
| 70 | _hash: 1357924680acegikmoqsuwybdfhjlnprtvxz␊ |
| 71 | </pre>␊ |
| 72 | <p>␊ |
| 73 | Together with your login, you will be able to use those values to␊ |
| 74 | authenticate a query.␊ |
| 75 | </p>␊ |
| 76 | ␊ |
| 77 | {/block} {block context}␊ |
| 78 | <p>{trans 'Here we are, just to help you.'}</p>␊ |
| 79 | <h2>{trans 'Projects'}</h2>␊ |
| 80 | <ul>{foreach $projects as $p}␊ |
| 81 | <li><a href="{url 'IDF_Views_Project::home', array($p.shortname)}">{$p}</a></li>␊ |
| 82 | {/foreach}</ul>␊ |
| 83 | {/block}␊ |
| 84 | |