---
title: "Biocompile API quick start: a first call with curl and Python"
description: "Create a Biocompile personal access token, exchange it for an access token and list your organizations and research projects with curl or Python."
url: https://www.biocompile.com/docs/api-quickstart/
section: "API and integrations"
last_updated: 2026-11-03
app_url: https://app.biocompile.com/settings
---

# Biocompile API quick start: a first call with curl and Python

> Create a Biocompile personal access token, exchange it for an access token and list your organizations and research projects with curl or Python.

Source: https://www.biocompile.com/docs/api-quickstart/. Index of all Biocompile documentation: https://www.biocompile.com/docs/index.md

The Biocompile API quick start ends with a short script that lists your organizations and
their research projects. You create a personal access token in the app, exchange it for a
short-lived access token, and make your first calls with curl. The same calls in Python
follow the steps.

You need a Biocompile account and a terminal with `curl` and `jq` installed.

## Make your first API call

Every call uses an access token that lasts 10 minutes, exchanged from the personal access
token you create in the first step:

1. Open **Settings → API tokens** and choose **Create token**. Result: the
   **New personal access token** form opens.
2. Enter a **Name**, choose your organization under **Organization**, tick the
   `projects:read` scope and create the token. Result: the token is shown once, under
   "Copy it now. You won't see this again."
3. Copy the token and keep it in an environment variable, never in your code:

   ```bash
   export BIOCOMPILE_PAT='paste-your-token-here'
   ```

4. Exchange it for an access token at the token endpoint:

   ```bash
   ACCESS_TOKEN=$(curl -s https://app.biocompile.com/api/v1/oauth/token \
     -d grant_type=urn:ietf:params:oauth:grant-type:token-exchange \
     -d subject_token_type=urn:biocompile:params:oauth:token-type:pat \
     --data-urlencode "subject_token=$BIOCOMPILE_PAT" | jq -r .access_token)
   ```

   Result: `ACCESS_TOKEN` holds a token that works for 600 seconds.
5. List the organizations you belong to:

   ```bash
   curl -s https://app.biocompile.com/api/v1/organizations/ \
     -H "Authorization: Bearer $ACCESS_TOKEN"
   ```

   Result: the answer is `{"data": [...], "count": n}`, one entry per organization.
6. List the research projects of the first organization:

   ```bash
   ORG_ID=$(curl -s https://app.biocompile.com/api/v1/organizations/ \
     -H "Authorization: Bearer $ACCESS_TOKEN" | jq -r '.data[0]._id')

   curl -s "https://app.biocompile.com/api/v1/organizations/$ORG_ID/research-projects/?limit=20" \
     -H "Authorization: Bearer $ACCESS_TOKEN"
   ```

   Result: you see the projects you can open in the app, and no others.

After 10 minutes the API answers `401`. Exchange the personal access token again, ideally a
minute before the `expires_in` time of the exchange runs out.

## Make the same calls in Python

Any HTTP client works with the API. With `httpx`, the exchange and the first call look like
this:

```python
import os

import httpx

BASE = "https://app.biocompile.com"

grant = httpx.post(
    f"{BASE}/api/v1/oauth/token",
    data={
        "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
        "subject_token_type": "urn:biocompile:params:oauth:token-type:pat",
        "subject_token": os.environ["BIOCOMPILE_PAT"],
    },
).raise_for_status().json()

headers = {"Authorization": f"Bearer {grant['access_token']}"}
organizations = httpx.get(f"{BASE}/api/v1/organizations/", headers=headers)
organizations.raise_for_status()
for organization in organizations.json()["data"]:
    print(organization["_id"], organization["name"])
```

A script that runs longer than 10 minutes exchanges the token again before it expires.

## Next steps

- [API authentication](https://www.biocompile.com/docs/api-authentication.md)
- [API scopes and permissions](https://www.biocompile.com/docs/api-scopes.md)
- [Connect AI assistants over MCP](https://www.biocompile.com/docs/mcp-ai-assistants.md)

## Get access to Biocompile

Biocompile is used in the browser at https://app.biocompile.com. It is free to start and no payment method is required: sign up at https://app.biocompile.com/signup?mc_cta=docs-md&mc_path=/docs/api-quickstart.md. If your team already uses Biocompile, ask an organization admin to invite you. Research teams that want hands-on setup can apply for the founder-led pilot at https://www.biocompile.com/pilot/. Questions: https://www.biocompile.com/contact/.
