# The API

### About the API

Pathogenwatch provides an API enabling users to write scripts for interacting with Pathogenwatch, and for other databases to automatically extract data for their own use. For instance, the daily updated genome assemblies from the ENA can be directly queried and downloaded. The API is RESTful, and requires a user key for authentication.

{% hint style="danger" %}

### Rate limit your requests

If you are automating a series of queries, please ensure that you don't block our servers by sending all the requests at once.

We will block keys that are causing an issue, and may block users who repeatedly abuse the service. Please contact us if you have questions about how to use the API safely.
{% endhint %}

### Getting started

To access the API, the first step is generate an API key associated with a user account. Click on "My account" in the top right corner to access your account page, and then scroll to the bottom. The "API keys" section will list any keys you've already generated, and allows you to generate new ones.

{% hint style="warning" %}
It's recommended to generate a separate key for each application, particularly if they are long running servers. Then if one key is compromised or blocked, then other services will keep running.
{% endhint %}

<figure><img src="/files/eIJa4kZbe2ZUPKpJS3sV" alt=""><figcaption><p>The API key section is found at the bottom off the "My account" page</p></figcaption></figure>

Clicking "+Create Key" will bring up a request to name it. Enter the name and the key will be added to your API key section.

<figure><img src="/files/ONuuRbBaeoqoWVB3kTzo" alt="" width="375"><figcaption><p>The  key generation pop up. The key is named "my_pipeline" here.</p></figcaption></figure>

To view or copy the key use the eye and clipboard icons in the "Value" field respectively.

<figure><img src="/files/aIVHLOf9MUx6mwWFRBzf" alt=""><figcaption><p>The "my_pipeline" key has been added to the user account.</p></figcaption></figure>

### Using the API

The [API documentation](https://next.pathogen.watch/docs/api) comprehensively covers the possible queries. Sample queries can be interactively generated and possibilities explored. A few example queries are provided below.

{% hint style="info" %}
The complete API documentation can be found at <https://pathogen.watch/docs/api>, along with the OpenAPI specification.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cgps.gitbook.io/pathogenwatch/how-to-use-pathogenwatch/the-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
