Self hosted FLOSS fitness/workout, nutrition and weight tracker
Update the documentation for the REST API
Roland Geidercbdfa90439ca
diff --git a/wger/software/templates/api.html b/wger/software/templates/api.htmlindex 71d48355d..0347e84f5 100644--- a/wger/software/templates/api.html+++ b/wger/software/templates/api.html@@ -23,13 +23,63 @@ through the necessary endpoints without having to consult an extensivedocumentation. At the moment, the API only supports read operations, butsupport for full POST/PUT/DELETE/PATCH is planned for the near future.{% endblocktrans %}</p>+++<h3>{% trans "Fetching Data" %}</h3>+<!--+Many of the explanations are taken from+https://django-tastypie.readthedocs.org/en/latest/interacting.html+-->++<h4>Api-Wide</h4>+<code>+curl https://wger.de/api/v1/+</code>++<p>{% blocktrans %}This lists out all the different resources available. Each one+is listed by the resource_name and provides the list_endpoint and the schema+for the resource. Note that these links try to direct you to other parts of+the API, to make exploration/discovery easier.{% endblocktrans %}</p>++<h4>{% trans "Getting A Collection Of Resources" %}</h4>++<code>+curl https://wger.de/api/v1/foobar/+curl https://wger.de/api/v1/foobar/schema/+</code>+++<ul>+ <li>{% trans "By default, you get a paginated set of objects" %}</li>+ <li>{% trans "In the meta, you get a previous and next. If available, these are URIs to the previous and next pages." %}</li>+ <li>{% trans "You get a list of resources/objects under the objects key." %}</li>+ <li>{% trans "Each resources/object has a resource_uri field that points to the detail view for that object." %}</li>+ <li>{% trans "Foreign keys are represented as URIs." %}</li>+</ul>++<code>+curl https://wger.de/api/v1/foobar/1/+</code>++<p>{% blocktrans %}This simply returns the foobar resource with the ID 1.{% endblocktrans %}</p>++<code>+curl https://wger.de/api/v1/foobar/1/?bar=baz+curl https://wger.de/api/v1/foobar/set/1;3/+curl https://wger.de/api/v1/foobar/?offset=20&limit=20+</code>+<p>{% blocktrans %}You can filter the resources, assuming that bar is an attribute+of foobar. Alternatively you can just specify the IDs you need or provide an offset.{% endblocktrans %}</p>++++{% endblock %}++{% block sidebar %}<div class="alert alert-info" style="margin-top:1em;">{% blocktrans %}This is also new for us, if you plan on using the API,<a href="https://groups.google.com/group/wger">we'd love to hear from you</a>.{% endblocktrans %}</div>-{% endblock %}--{% block sidebar %}<p><a href="/api/v1/?format=json" class="btn btn-block">{% trans "Browse the API" %}</a></p><p><a href="{% url 'api-key' %}" class="btn btn-block">Generate API KEY</a></p>