<aclass="reference internal"href="Webserver.html"><spanclass="doc std std-doc">Webserver</span></a> page, except the views will here return <aclass="reference external"href="https://en.wikipedia.org/wiki/JSON">JSON</a>
<p>The main controlling setting is <codeclass="docutils literal notranslate"><spanclass="pre">REST_FRAMEWORK</span></code>, which is a dict. The keys
<codeclass="docutils literal notranslate"><spanclass="pre">DEFAULT_LIST_PERMISSION</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">DEFAULT_CREATE_PERMISSIONS</span></code> control who may
view and create new objects via the api respectively. By default, users with
<aclass="reference internal"href="Permissions.html"><spanclass="doc std std-doc">‘Builder’-level permission</span></a> or higher may access both actions.</p>
<p>While the api is meant to be expanded upon, Evennia supplies several operations
out of the box. If you click the <codeclass="docutils literal notranslate"><spanclass="pre">Autodoc</span></code> button in the upper right of the <codeclass="docutils literal notranslate"><spanclass="pre">/api</span></code>
website you’ll get a fancy graphical presentation of the available endpoints.</p>
<p>Here is an example of calling the api in Python using the standard <codeclass="docutils literal notranslate"><spanclass="pre">requests</span></code> library.</p>
<p>In the above example, it now displays the objects inside the “results” array,
while it has a “count” value for the number of total objects, and “next” and
“previous” links for the next and previous page, if any. This is called
<aclass="reference external"href="https://www.django-rest-framework.org/api-guide/pagination/">pagination</a>, and the link displays “limit” and “offset” as query
parameters that can be added to the url to control the output.</p>
<p>Other query parameters can be defined as <aclass="reference external"href="https://www.django-rest-framework.org/api-guide/filtering/#filtering">filters</a> which allow you to
further narrow the results. For example, to only get accounts with developer
<p>Now suppose that you want to use the API to create an <aclass="reference internal"href="Objects.html"><spanclass="doc std std-doc">Object</span></a>:</p>
<divclass="highlight-none notranslate"><divclass="highlight"><pre><span></span>>>> data = {"db_key": "A shiny sword"}
<p>Here we made a HTTP POST request to the <codeclass="docutils literal notranslate"><spanclass="pre">/api/objects</span></code> endpoint with the <codeclass="docutils literal notranslate"><spanclass="pre">db_key</span></code>
we wanted. We got back info for the newly created object. You can now make
another request with PUT (replace everything) or PATCH (replace only what you
provide). By providing the id to the endpoint (<codeclass="docutils literal notranslate"><spanclass="pre">/api/objects/214</span></code>),
<p>In most cases, you won’t be making API requests to the backend with Python,
but with Javascript from some frontend application.
There are many Javascript libraries which are meant to make this process
easier for requests from the frontend, such as <aclass="reference external"href="https://github.com/axios/axios">AXIOS</a>, or using
the native <aclass="reference external"href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API">Fetch</a>.</p>
</section>
<sectionid="customizing-the-api">
<h2>Customizing the API<aclass="headerlink"href="#customizing-the-api"title="Permalink to this headline">¶</a></h2>
<p>Overall, reading up on <aclass="reference external"href="https://www.django-rest-framework.org/api-guide/viewsets">Django Rest Framework ViewSets</a> and
other parts of their documentation is required for expanding and
<p>Check out the <aclass="reference internal"href="Website.html"><spanclass="doc std std-doc">Website</span></a> page for help on how to override code, templates
<li><p>API templates (for the web-display) is located in <codeclass="docutils literal notranslate"><spanclass="pre">evennia/web/api/templates/rest_framework/</span></code> (it must
be named such to allow override of the original REST framework templates).</p></li>
<li><p>Static files is in <codeclass="docutils literal notranslate"><spanclass="pre">evennia/web/api/static/rest_framework/</span></code></p></li>
<li><p>The api code is located in <codeclass="docutils literal notranslate"><spanclass="pre">evennia/web/api/</span></code> - the <codeclass="docutils literal notranslate"><spanclass="pre">url.py</span></code> file here is responsible for