Skip to main content
ELIXIR On-Cloud

FOCA

License Build_status Docs Coverage GitHub_tag Docker_image PyPI_release DOI

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;
  • a plugin engine for gateway apps (e.g., proTES): installed, versioned plugins that check, change and route requests to backends, in pipelines set by operators;
  • an HTTP client for untrusted URLs, guarded against server-side request forgery;
  • 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.21.0 (from 0.19 or earlier, first Migrating to 0.20.0, from 0.17 or earlier also Migrating to 0.18.0, Migrating to 0.17.0, 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 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 to 3.15) 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.

Citation

If you use FOCA, please cite it with its DOI 10.5281/zenodo.23603534, which always resolves to the latest version on Zenodo; the Zenodo record lists the DOI of each version, too. The citation metadata is in CITATION.cff: on GitHub, "Cite this repository" in the sidebar of the repository formats it as APA or BibTeX.

Contributing

Contributions are welcome! See Contributing in the documentation and the organisation's contributing guide, and mind our code of conduct.

Metadata

Release files for foca 0.21.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for foca 0.21.0
File Size Uploaded Provenance Actions
foca-0.21.0.tar.gz 641.3 kB With provenance Details for foca-0.21.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for foca 0.21.0
File Interpreter ABI Platform Actions
foca-0.21.0-py3-none-any.whl Python 3 none any Details for foca-0.21.0-py3-none-any.whl

Total release size: 979.6 kB

Release files / foca-0.21.0.tar.gz

Download URL foca-0.21.0.tar.gz
Size 641.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0b1187c5b4ef23bcb9cf9b24da841cd32df15378e3f7ddc9876f9b928127c650
BLAKE2b-256 checksum
How to use checksums
7d3c30e645f663616c100307736259cfebcbbfd0e931ffce8d492de14042496a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 5, 2026.

Transparency log

Release files / foca-0.21.0-py3-none-any.whl

Download URL foca-0.21.0-py3-none-any.whl
Size 338.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45d1653a6f7a3c8ec0e44c68e8d47d01897358b74b60d459ef4dc8d2e2a5d468
BLAKE2b-256 checksum
How to use checksums
81f2ea5d20b4c998c5a74193764078d0972585a8f473826070f8e44f4bd05460
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 5, 2026.

Transparency log

Security for foca 0.21.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for foca-0.21.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 Nov 5, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page