# Downloads

pATLAS database requests can be done through URLs, similar to what is done in [eutils](https://www.ncbi.nlm.nih.gov/books/NBK25500/) .

## Download metadata

### From a browser

If you have a list of accession numbers present in pATLAS database, you can download all metadata through:

```
http://www.patlas.site/api/sendmetadata/?accession=<accession_list>
```

or

```
http://www.patlas.site/api/sendmetadata?accession=<accession_list>
```

It will fetch an array of json objects in which each contains all metadata available for that accession number.

E.g.:

```
http://www.patlas.site/api/sendmetadata?accession=NC_017393_1,NZ_CP009835_1
```

### From a terminal

#### TL;DR

```python
import requests

r = requests.post("http://www.patlas.site/api/sendmetadata/",
json=["NC_017393_1", "NZ_CP009835_1"])

r.content
# your results
```

#### Explanation

* Send the post to `http://www.patlas.site/results/`.
* Send a `json` with the request. This `json` must contain a list of

  accession numbers

## Download sequences

The sequences of plasmids from pATLAS database can be downloaded through the following API when providing a list of the accession numbers:

```
http://www.patlas.site/api/senddownload/?accession=<accession_list>
```

It will generate a fasta file with the accession numbers requested and the sequences associated with each accession number.

**Limitation**: This type of request to pATLAS database cannot have thousands of accessions therefore for requests with thousands of accessions, use the following request type:

Python:

```python
import requests

# Note that form data should be sent as a string and using 'data' instead of 'json'
r = requests.post("http://www.patlas.site/api/senddownload/",
data={"accessions": '["NC_017393_1", "NZ_CP009835_1"]'})

r.content
# result: http://patlas.site/results?query=15675682358507007771
```

Javascript / JQuery:

```javascript
// Note that form data should be sent as a string
$.post("www.patlas.site/api/senddownload/", {"accessions": JSON.stringify(["NC_017393_1", "NZ_CP009835_1"])}, (data, status) => {
      if (status === "success") {
        console.log(data)
        // result: http://patlas.site/results?query=15675682358507007771
      }
    }
  )
```

**Note** - The `download` button in the top bar downloads the accession numbers associated with the current selection using this last API, so it is possible to download the full pATLAS data set. See [Top navigation bar](/docs/usage/topbar.md) for more information. [Download button in table](/docs/usage/topbar/table.md#download-button) also uses this API.


---

# 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://patlas.gitbook.io/docs/api/download_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.
