123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- {% extends "layout.html" %}
- {% block page_title %}REST API <small>v1 alpha</small>{% endblock %}
- {% block head -%}
- {{ super() }}
- <link rel=stylesheet type=text/css href="{{ url_for('static', filename='css/highlight_github.css') }}">
- {%- endblock %}
- {% block script -%}
- {{ super() }}
- <script type="text/javascript" src="{{ url_for('static', filename='js/highlight.pack.js') }}"></script>
- <script type="text/javascript">hljs.initHighlightingOnLoad();</script>
- {%- endblock %}
- {% block body %}
- <link rel=stylesheet type=text/css href="/static/css/highlight_github.css">
- <p>The API lives at <code>/api/v1/</code>. The format used is JSON.</p>
- <h3>Collections</h3>
- <h4>ISPs</h4>
- <div class="api-collection" id="api-collection-isp">
- <div class="api-doc-resource">
- <div class="api-doc-heading">
- <span class="label label-info" data-toggle="collapse" href="#api-isp-1">GET</span>
- <a class="path" data-toggle="collapse" href="#api-isp-1">/isp/</a>
- <a class="description" data-toggle="collapse" href="#api-isp-1">
- returns all ISPs in database
- </a>
- </div>
- <div id="api-isp-1" class="api-doc-body collapse">
- <div class="api-doc-inner">
- <h5>Parameters</h5>
- <table class="table table-bordered table-striped">
- <thead>
- <tr>
- <th style="width: 100px;">Name</th>
- <th>Value</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>page</code></td>
- <td>int</td>
- <td>Page number</td>
- </tr>
- <tr>
- <td><code>per_page</code></td>
- <td>int</td>
- <td>Number of items per page</td>
- </tr>
- <tr>
- <td><code>range</code></td>
- <td>int,int</td>
- <td>Range to return, in the format offset,value</td>
- </tr>
- </tbody>
- </table>
- <h5>Output</h5>
- <p>This resource returns an array of ISP objects.</p>
- <h5>Sample output</h5>
- <p>When using pagination (default) :</p>
- <pre><code>{
- "total_items": 3,
- "page": 1,
- "num_pages": 1,
- "per_page": 10,
- "isps": [
- /* list of ISP objects */
- ]
- }</code></pre>
- <p>When providing a range parameter :</p>
- <pre><code>{
- "total_items": 3,
- "range": "0,1",
- "isps": [
- /* list of ISP objects */
- ]
- }</code></pre>
- <h5>Status code</h5>
- <p>This resource can return the following status codes: <code>400</code>, <code>500</code>.</p>
- </div>
- </div>
- </div>
- <div class="api-doc-resource">
- <div class="api-doc-heading">
- <span class="label label-info" data-toggle="collapse" href="#api-isp-2">GET</span>
- <a class="path" data-toggle="collapse" href="#api-isp-2">/isp/<int:isp_id>/</a>
- <a class="description" data-toggle="collapse" href="#api-isp-2">
- returns the ISP with id <isp_id>
- </a>
- </div>
- <div id="api-isp-2" class="api-doc-body collapse">
- <div class="api-doc-inner">
- <h5>Output</h5>
- <p>This resource returns an ISP object or an ObjectNotFound error.</p>
- <h5>Status code</h5>
- <p>This resource can return the following status codes: <code>404</code>, <code>400</code>, <code>500</code>.</p>
- </div>
- </div>
- </div>
- <div class="api-doc-resource">
- <div class="api-doc-heading">
- <span class="label label-info" data-toggle="collapse" href="#api-isp-3">GET</span>
- <a class="path" data-toggle="collapse" href="#api-isp-3">/isp/<int:isp_id>/covered_areas/</a>
- <a class="description" data-toggle="collapse" href="#api-isp-3">
- returns the covered areas for ISP with id <isp_id>
- </a>
- </div>
- <div id="api-isp-3" class="api-doc-body collapse">
- <div class="api-doc-inner">
- <h5>Parameters</h5>
- <table class="table table-bordered table-striped">
- <thead>
- <tr>
- <th style="width: 100px;">Name</th>
- <th>Value</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>page</code></td>
- <td>int</td>
- <td>Page number</td>
- </tr>
- <tr>
- <td><code>per_page</code></td>
- <td>int</td>
- <td>Number of items per page</td>
- </tr>
- <tr>
- <td><code>range</code></td>
- <td>int,int</td>
- <td>Range to return, in the format offset,value</td>
- </tr>
- </tbody>
- </table>
- <h5>Output</h5>
- <p>This resource returns an array of CoveredArea objects belonging to a given ISP. Note that the CoveredArea objects don't have an "isp" attribute since we assume the client will have retrieved informations about the ISP beforehand.</p>
- <h5>Status code</h5>
- <p>This resource can return the following status codes: <code>404</code>, <code>400</code>, <code>500</code>.</p>
- </div>
- </div>
- </div>
- <div class="api-doc-resource">
- <div class="api-doc-heading">
- <span class="label label-info" data-toggle="collapse" href="#api-isp-4">GET</span>
- <a class="path" data-toggle="collapse" href="#api-isp-4">/isp/export_urls/</a>
- <a class="description" data-toggle="collapse" href="#api-isp-4">
- returns all isp-format urls
- </a>
- </div>
- <div id="api-isp-4" class="api-doc-body collapse">
- <div class="api-doc-inner">
- <h5>Output</h5>
- <p>This resource returns a list of all ISP Format URLs in database.</p>
- <h5>Status code</h5>
- <p>This resource can return the following status codes: <code>500</code>.</p>
- </div>
- </div>
- </div>
- </div>
- <hr style="margin: 15px 0 0 0;" />
- <h4>Covered Areas<small> : Areas covered by ISPs</small></h4>
- <div class="api-collection" id="api-collection-isp">
- <div class="api-doc-resource">
- <div class="api-doc-heading">
- <span class="label label-info" data-toggle="collapse" href="#api-area-1">GET</span>
- <a class="path" data-toggle="collapse" href="#api-area-1">/covered_area/</a>
- <a class="description" data-toggle="collapse" href="#api-area-1">
- returns all Covered Areas in database
- </a>
- </div>
- <div id="api-area-1" class="api-doc-body collapse">
- <div class="api-doc-inner">
- <h5>Parameters</h5>
- <table class="table table-bordered table-striped">
- <thead>
- <tr>
- <th style="width: 100px;">Name</th>
- <th>Value</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>page</code></td>
- <td>int</td>
- <td>Page number</td>
- </tr>
- <tr>
- <td><code>per_page</code></td>
- <td>int</td>
- <td>Number of items per page</td>
- </tr>
- <tr>
- <td><code>range</code></td>
- <td>int,int</td>
- <td>Range to return, in the format offset,value</td>
- </tr>
- </tbody>
- </table>
- <h5>Output</h5>
- <p>This resource returns an array of CoveredArea objects.</p>
- <h5>Sample output</h5>
- <p>When using pagination (default) :</p>
- <pre><code>{
- "total_items": 3,
- "page": 1,
- "num_pages": 1,
- "per_page": 10,
- "covered_areas": [
- /* list of CoveredArea objects */
- ]
- }</code></pre>
- <p>When providing a range parameter :</p>
- <pre><code>{
- "total_items": 3,
- "range": "0,1",
- "covered_areas": [
- /* list of CoveredArea objects */
- ]
- }</code></pre>
- <h5>Status code</h5>
- <p>This resource can return the following status codes: <code>404</code>, <code>400</code>, <code>500</code>.</p>
- </div>
- </div>
- </div>
- <div class="api-doc-resource">
- <div class="api-doc-heading">
- <span class="label label-info" data-toggle="collapse" href="#api-area-2">GET</span>
- <a class="path" data-toggle="collapse" href="#api-area-2">/covered_area/<int:area_id>/</a>
- <a class="description" data-toggle="collapse" href="#api-area-2">
- returns the Area with id <area_id>
- </a>
- </div>
- <div id="api-area-2" class="api-doc-body collapse">
- <div class="api-doc-inner">
- <h5>Output</h5>
- <p>This resource returns a CoveredArea object or an ObjectNotFound error.</p>
- <h5>Status code</h5>
- <p>This resource can return the following status codes: <code>404</code>, <code>400</code>, <code>500</code>.</p>
- </div>
- </div>
- </div>
- </div>
- <h3 style="margin-top: 30px;">Objects</h3>
- <h4>ISP</h4>
- <pre><code>{
- "id": "int",
- "is_ffdn_member": "bool",
- "json_url": "string:url",
- "date_added": "string:ISO8601 datetime",
- "last_update": "string:ISO8601 datetime",
- "ispformat": "object:ISP Format"
- }</code></pre>
- <h4>CoveredArea</h4>
- <pre><code>{
- "id": "int",
- "isp": {
- "id": "int",
- "name": "string",
- "shortname": "string|null"
- },
- "name": "string",
- "geojson": "object:GeoJSON"
- }</code></pre>
- <h3 style="margin-top: 30px;">Errors</h3>
- <p>A typical error response looks like this:</p>
- <pre><code>{
- "error": {
- "message": "There was an error while processing your request",
- "error_type": "ispdb.api.InternalError"
- }
- }</code></pre>
- <p>Message is an informative message regarding the error, error_type is an optionnal field containing the error class, which can give machine-readable informations about the error.</p>
- <p>For now, the following error class are defined:</p>
- <div class="row">
- <table class="table table-bordered table-striped span10" style="background-color: #fff">
- <thead>
- <tr>
- <th style="width: 200px;">Error class</th>
- <th style="width: 100px;">Status code</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>ispdb.api.ObjectNotFound</code></td>
- <td>404</td>
- <td>Could not find the item matching the criterias you specified</td>
- </tr>
- <tr>
- <td><code>ispdb.api.BadInput</code></td>
- <td>400</td>
- <td>Invalid input</td>
- </tr>
- <tr>
- <td><code>ispdb.api.InternalError</code></td>
- <td>500</td>
- <td>Internal server error</td>
- </tr>
- </tbody>
- </table>
- </div>
- {%- endblock %}
|