FOCA
An archetype for OpenAPI-based web services in Python, brought to you by ELIXIR On-Cloud. FOCA (Flask-OpenAPI-Connexion-Archetype) builds a Connexion app on Flask from your OpenAPI specifications and a single configuration file, so that you only write the controllers and the logic of your app. It provides:
- OpenAPI 2.x/3.x specifications, validated and routed by Connexion and modified on the fly;
- a validated, typed configuration, with environment-specific overlays;
- errors as problem details;
- bearer token validation for the OpenID Connect providers that you trust;
- access control with Casbin: policies on all operations, roles of users and groups, resource ownership and a permissions API;
- MongoDB databases, collections and indexes;
- background tasks with Celery and RabbitMQ;
- CORS and a GA4GH service info endpoint;
- Docker base images with SBOM and provenance attestations, and a Helm library chart for Kubernetes with a provenance attestation, all signed.
Read the documentation for the configuration, authentication, access control, the deployment with Docker and Helm, the utilities, the API reference and development. Upgrading from an earlier version? See Migrating to 0.17.0 (from 0.15 or earlier, first Migrating to 0.16.0, Migrating to 0.15.0 and Migrating to 0.14.0).
Why FOCA
FOCA's package has about 9,300 lines of code, tested by about 12,600 lines of tests, and its Helm library chart about 1,750 lines. Cloud Registry, for example, uses almost all of the package (all but the Celery factory and a database helper) and has about 2,200 lines of code of its own, plus about 9,000 lines of tests. Its own code is thus about a fifth of what it would be without FOCA, counting code only, and about a third, counting code and tests. Even if an app needed only half of FOCA's code, FOCA would still save it about 4,500 lines, plus their tests and the chart. (Lines of Python without blank lines and comments, docstrings included; FOCA 0.17.0 and Cloud Registry in October 2026.)
The savings add up with every app: if you maintain several OpenAPI-based apps, they all share the same authentication, access control, configuration, errors, images and Helm chart, and security fixes and upgrades are made once, in FOCA, instead of in every app.
Apps built with FOCA
| App | Description |
|---|---|
| Cloud Registry | A registry of web services, implementing the GA4GH Service Registry API |
| proTES | A gateway for the GA4GH Task Execution Service (TES) API that federates TES instances |
See also the dependents of FOCA on
GitHub. Built an
app with FOCA? Open a pull request that adds it to the table in
README.md.
Quick start
Install the FOCA package (Python 3.11 or later) with pip:
pip install foca
Write a configuration file that points to your OpenAPI
specification and the module of its controllers, e.g., config.yaml:
api:
specs:
my-api:
path: api/openapi.yaml
add_operation_fields:
x-openapi-router-controller: my_app.controllers
Then create and run your app:
from foca import Foca
app = Foca(config_file="config.yaml").create_app() # Connexion app
if __name__ == "__main__":
app.run()
See Getting started for a step-by-step guide and the Docker image, and the Petstore example app to see FOCA in action.
Contributing
Contributions are welcome! See CONTRIBUTING.md and
Contributing in the documentation, and mind our code of
conduct.
Metadata
Release files for foca 0.17.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| foca-0.17.0.tar.gz | 249.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| foca-0.17.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 377.0 kB
Release files / foca-0.17.0.tar.gz
| Download URL | foca-0.17.0.tar.gz |
|---|---|
| Size | 249.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26f87b3a1332bd3163590fb98a0cfbed85848fc65c6ff483c552f4ae809f228c
|
|
BLAKE2b-256 checksum How to use checksums |
f704423707cf7f28fc8574befcd654491cfb6c92e8663ead51ef98b8c9f8f93d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logRelease files / foca-0.17.0-py3-none-any.whl
| Download URL | foca-0.17.0-py3-none-any.whl |
|---|---|
| Size | 127.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fffbe0f39a908c472997999ee43238eea7c498cb0eaf1fe0423514248edede48
|
|
BLAKE2b-256 checksum How to use checksums |
77b6e2ac6c9c96010ee7fc45d287070dad0de0ba72720c20aa8bf277b0c55f18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logSecurity for foca 0.17.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for foca-0.17.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.