Python client and CLI for the METT Data Portal API
Project description
METT Data Portal Client
Python client library and command-line interface (CLI) for the Microbial Ecosystems Transversal Themes (METT) Data Portal.
- Portal: http://www.gut-microbes.org/
- Install from PyPI:
pip install mett - Python import package:
mett_client
Features
- 🚀 High-level Python API - Clean, intuitive interface for programmatic access
- 💻 Command-line Interface - CLI with rich output and shell completion
- 📊 Multiple Output Formats - JSON, TSV, and formatted tables
- 🔒 Flexible Configuration - Environment variables and config file support
- 📚 Documentation - Usage examples and API details
- 🔄 Auto-generated SDK - Stays in sync with the API schema
Quick Start
Installation
pip install mett
CLI Usage
# List all species
mett species list
# Search genomes
mett genomes search --query "Bacteroides" --per-page 5
# Get gene information
mett genes get BU_ATCC8492_00001
Python API
from mett_client import DataPortalClient
# Initialize client
client = DataPortalClient()
# List species
species = client.list_species()
print(f"Found {len(species)} species")
# List genomes (paginated)
result = client.list_genomes(per_page=5)
print(f"Found {len(result.items)} genomes")
# Search genomes by species
result = client.species_genomes("BU", per_page=5)
print(f"Found {len(result.items)} BU genomes")
# Search genomes with query
result = client.search_genomes(query="ATCC", per_page=5)
print(f"Found {len(result.items)} genomes matching 'ATCC'")
# Search genomes - check first genome
if result.items:
print(f"First genome: {result.items[0].isolate_name}")
Configuration
The client/CLI can be configured using environment variables (recommended for CI and local dev) or a config file (if supported by your implementation).
Common environment variables
# Base URL for the METT Data Portal API (if your client supports overriding it)
export METT_BASE_URL="https://www.gut-microbes.org/"
# If the API requires authentication (token / key), set it here (adjust name to match your implementation)
# export METT_API_TOKEN="..."
# SSL verification (useful for dev environments without certificates)
export METT_VERIFY_SSL=false
Documentation
Complete documentation is available in the docs/ directory:
- Getting Started - Overview and quick start
- CLI Guide - Command-line interface
- Python API - Python client library
- Configuration - Setup and authentication
- Troubleshooting - Common issues and solutions
Source & Support
- Source repository: https://github.com/EBI-Metagenomics/mett-dataportal-client
- Issues / feature requests: https://github.com/EBI-Metagenomics/mett-dataportal-client/issues
Development
From Source (with uv) — recommended
git clone https://github.com/EBI-Metagenomics/mett-dataportal-client.git
cd mett-dataportal-client
# Create a virtual environment and install all dependencies from pyproject.toml
uv sync --all-extras --dev
# Run the CLI via uv (no manual activation needed)
uv run mett --help
Running tests and linting (with uv)
# Install all dev dependencies (if not already done)
uv sync --all-extras --dev
# Run tests
uv run pytest -v
# Run Ruff lint and formatting checks
uv run ruff check mett_client/ scripts/ tests/
uv run ruff format --check mett_client/ scripts/ tests/
# (Optional) Run pre-commit hooks on all files
uv run pre-commit run --all-files
Alternative (classic pip workflow)
If you prefer not to use uv, you can still work with a standard virtual environment:
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -e ".[dev]"
# CLI is now on PATH inside the venv
mett --help
Requirements
- Python 3.10+
- See
pyproject.tomlfor full dependency list
License
Apache-2.0 License - see LICENSE file for details.
Note: For development environments without SSL certificates, you may need to set:
export METT_VERIFY_SSL=false
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mett-0.0.1a7.tar.gz.
File metadata
- Download URL: mett-0.0.1a7.tar.gz
- Upload date:
- Size: 94.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8efb87bfc9a5804412aeebb8ecd68c5e9d362d6c3b532b758c0ed081bbcad2ad
|
|
| MD5 |
650d9103a72c9eafb314f7740f1c88a3
|
|
| BLAKE2b-256 |
98e0a687c0bb867b41194a33cac1935cf7171d8ab1794b2841cf118c519f429a
|
File details
Details for the file mett-0.0.1a7-py3-none-any.whl.
File metadata
- Download URL: mett-0.0.1a7-py3-none-any.whl
- Upload date:
- Size: 203.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c43275b80ac14ac07187703bac93670e5c4a9d40dcbcfbe04ffec37c0da00b88
|
|
| MD5 |
157cb77b8829017cecf37b96e45a8fd9
|
|
| BLAKE2b-256 |
0b27e74d89b84f0e66c6dbbe26b6c299ae3e6ad9bd3941718fd6c25a2b0eee75
|