Skip to main content

REST API for Riftbound catalogue, collections, decks, validation, and analysis.

Project description

riftbound-api

API REST FastAPI pour consulter les données Riftbound, gérer des collections et des decks, puis orchestrer la validation et l'analyse via riftbound-core et riftbound-database.

Version actuelle : 0.6.0 (pré-1.0, persistance PostgreSQL collection/decks).

Installation

Prérequis : Python 3.12 ou 3.13.

python -m pip install riftbound-api

Avec le driver PostgreSQL recommandé en production :

python -m pip install "riftbound-api[postgres]"

Développement local :

python -m pip install -e ".[dev]"

Démarrage rapide

export RIFTBOUND_DATABASE_URL="postgresql+psycopg://user:password@localhost:5432/riftbound"
uvicorn riftbound_api.main:app --host 0.0.0.0 --port 8000

Sans base configurée, les routes catalogue, collection et decks renvoient 503 DATABASE_UNAVAILABLE.

Documentation interactive : GET /docs et GET /openapi.json.

Configuration

Variable Obligatoire Défaut Rôle
RIFTBOUND_DATABASE_URL Oui (prod) URL PostgreSQL (postgresql+psycopg://…)
RIFTBOUND_API_ENV Non development Environnement
RIFTBOUND_API_LOG_LEVEL Non INFO Niveau de log JSON
RIFTBOUND_API_CORS_ORIGINS Non vide Origines CORS autorisées
RIFTBOUND_API_AUTH_MODE Non disabled disabled, api_key ou oidc (réservé)
RIFTBOUND_API_DEV_USER_ID Non dev-user Utilisateur injecté en mode disabled
RIFTBOUND_API_API_KEYS Non vide Clés API key:user_id ou JSON

Les secrets ne sont jamais loggés. Chaque réponse d'erreur inclut un request_id (X-Request-Id).

Endpoints principaux

Domaine Exemples
Système GET /health, GET /version
Catalogue GET /cards, GET /cards/{card_id}
Références GET /sets, GET /rules/current, GET /keywords, GET /formats
Collection GET /collections/me, POST /collections/me/cards
Decks GET /decks, POST /decks, POST /decks/{id}/validate, POST /decks/{id}/analyze
Import/export POST /decks/import, POST /decks/{id}/export
Validation inline POST /deck-validation

Spécification complète : docs/.

Migrations base de données

Les migrations sont fournies par riftbound-database :

python -m pip install riftbound-database
riftbound-db upgrade

Tests d'intégration PostgreSQL

Prérequis locaux : Docker.

Les tests marqués postgresql démarrent automatiquement un conteneur éphémère (docker compose, projet riftbound-api-pytest) puis l'arrêtent et le suppriment à la fin de la session pytest.

python -m pytest -m postgresql -q

Pour réutiliser une base déjà disponible (CI ou instance locale) :

export RIFTBOUND_TEST_POSTGRESQL_URL="postgresql+psycopg://postgres:postgres@localhost:5432/riftbound_test"
python -m pytest -m postgresql -q

Pour un PostgreSQL manuel persistant (hors pytest) :

docker compose up -d

Limitations connues (0.6.0)

  • Authentification OIDC : RIFTBOUND_API_AUTH_MODE=oidc est réservé et rejeté au démarrage.
  • Snapshots de validation API : repository mémoire process (non persistés PostgreSQL).
  • Snapshots d'analyse deck : non implémentés côté API.

Frontière de persistance

riftbound-api dépend de riftbound-database pour le provider, les sessions, les repositories catalogue, les transactions et les migrations. baobab-database reste encapsulé et n'est jamais utilisé directement par l'API.

SQLAlchemy est déclaré uniquement pour classifier ses exceptions publiques lors du mapping HTTP. L'API ne définit aucun modèle, repository, moteur ou migration SQLAlchemy propre.

Qualité

python -m ruff check .
python -m mypy src tests
python -m coverage run -m pytest -m "not integration and not postgresql" -q
python -m coverage report --fail-under=85

Licence

MIT — voir LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

riftbound_api-0.6.0.tar.gz (148.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

riftbound_api-0.6.0-py3-none-any.whl (126.2 kB view details)

Uploaded Python 3

File details

Details for the file riftbound_api-0.6.0.tar.gz.

File metadata

  • Download URL: riftbound_api-0.6.0.tar.gz
  • Upload date:
  • Size: 148.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for riftbound_api-0.6.0.tar.gz
Algorithm Hash digest
SHA256 d88643c9189ad10e54c14a06b08ead3cb0dc77b7b28c65dcc23418f49da30d1c
MD5 98cd99e99978e27bdb6c59af15711f7c
BLAKE2b-256 5b9131e908892d4420bb6becbdd22af62d5c8e50c3672b072250c03aa0e63c0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for riftbound_api-0.6.0.tar.gz:

Publisher: release.yml on baobabgit/riftbound-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file riftbound_api-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: riftbound_api-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 126.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for riftbound_api-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7318cadde0640911266279c205c3fcc60a85a8a414dc31578c002e9505b2e30e
MD5 ebc7b9152f6cab3b93089c7fa3632c5d
BLAKE2b-256 f0b94be112a20af5546c7d42865e57b7da914a570da0d02e0411e3afaf41337f

See more details on using hashes here.

Provenance

The following attestation bundles were made for riftbound_api-0.6.0-py3-none-any.whl:

Publisher: release.yml on baobabgit/riftbound-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page