BEDbase API

Welcome to the BEDbase API. You might be looking for:

Bulk metadata export

If you want metadata for every BED file or BEDset, do not crawl the list endpoints. Download the monthly Parquet snapshot instead. It is one request, it is served from a CDN, and it does not touch the database.

Each snapshot is three Parquet files plus a JSON manifest, all dated the same day:

Pick the newest metadata entry and read it directly with pandas:

import pandas as pd
import requests

exports = requests.get("https://api.bedbase.org/v1/exports").json()["results"]
url = next(e["file_path"] for e in exports if e["file_type"] == "metadata")
df = pd.read_parquet(url)

Resolve the file through /v1/exports rather than hardcoding a name. Files are dated and immutable, so a new one appears each month.

Paging

/v1/bed/list returns records ordered by id. Two ways to page:

The count field (the total number of matching records) is only filled in on the first page (offset=0 and no after). On every other page it is null.

To walk every BED file for one genome:

import requests

base = "https://api.bedbase.org/v1/bed/list"
after = None
while True:
    params = {"genome": "hg38", "limit": 1000}
    if after:
        params["after"] = after
    page = requests.get(base, params=params).json()
    if not page["results"]:
        break
    for record in page["results"]:
        ...  # do something with each record
    after = page["results"][-1]["id"]

If you find yourself doing this for the whole database, use the bulk export above instead.

/v1/bedset/list is also ordered by id, and pages with limit (max 10000) and offset.