Requests Made from the Client
=============================

The Auspice client will make a number of requests to various endpoints, which this document aims to provide an overview of. Some of these are dependent on the `build-time customisations <./api>`__ in use, and we plan to allow more flexibility here using this mechanism.

Requests to the Auspice Server
------------------------------

For the purposes of this section we are assuming you are running locally on "localhost:4000", however the idea is the same if Auspice is deployed to a server.

Auspice Client JavaScript Code
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The (bundled) client code (which is generated by ``auspice build``) is broken up into a number of "chunks" which are delivered to the client as needed. These originate from the following block in the ``index.html`` file:

.. code:: html

   <script async src="/dist/auspice.bundle.js"></script>

"Charon" GET requests
~~~~~~~~~~~~~~~~~~~~~

When a dataset, narrative, or listing of available datasets is to be displayed in Auspice, a selection of the following requests are made to localhost:4000.

-  ``/charon/getAvailable`` -- return a list of available datasets and narratives
-  ``/charon/getDataset`` -- return the requested dataset
-  ``/charon/getNarrative`` -- return the requested narrative

See :doc:`the server API documentation <../server/api>` for more details about the requests, or the :doc:`client customisation API <api>` for the ability to change "/charon" to a different value.

Image Requests
~~~~~~~~~~~~~~

The initial Auspice page (i.e. the one which displays a listing of available datasets) requests some images for the footer.

External Requests
-----------------

Fonts
~~~~~

Two initial requests for fonts are made, for `Google-hosted Lato fonts (CSS) <https://fonts.googleapis.com/css?family=Lato:100,200,300,400,500,700>`__ and `font-awesome (CSS) <https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css%22%3E>`__. These in turn make a number of subsequent requests for the individual font files etc.

Leaflet
~~~~~~~

We use `Leaflet <https://leafletjs.com/>`__ to display the map tiles. There is one `initial CSS request <https://unpkg.com/leaflet@1.0.1/dist/leaflet.css>`__ which is always made, regardless of whether a map is displayed.

If a map is displayed by Auspice the individual tiles are requested from api.mapbox.com. Panning and zooming of the map result in futher requests for tiles. These are requested using our hardcoded access key, however this may change to a build-time-customisation in the future.

Web Analytics (Optional)
~~~~~~~~~~~~~~~~~~~~~~~~

Auspice has the potential to include either Plausible Analytics or Google Analytics in a limited fashion. See :ref:`the client customisation API documentation <client-api-available-customisations>` for how to set this. Note that these requests are only made if you set up build-time customisation of the client. (For nextstrain.org we use `Plausible analytics <https://github.com/nextstrain/nextstrain.org/blob/2685e6b363cf70808fa11ee38ac520dfb3a9cdc4/auspice-client/customisations/config.json#L14>`__.)
