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.18.0 (from 0.16 or earlier, first 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.md and Contributing in the documentation, and mind our code of conduct.

Metadata

Release files for foca 0.18.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.18.0
File Size Uploaded Provenance Actions
foca-0.18.0.tar.gz 468.3 kB With provenance Details for foca-0.18.0.tar.gz

Built distribution (wheel)

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

Total release size: 732.7 kB

Release files / foca-0.18.0.tar.gz

Download URL foca-0.18.0.tar.gz
Size 468.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b345181838a789599d33bab4163c98e3b4ace5009650c79afb45a2d80db4c9f3
BLAKE2b-256 checksum
How to use checksums
458617f0218c86d32ab0d4a6e8f0343a8510568a402c7aa6bf226cb32b19ab23
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 Oct 27, 2026.

Transparency log

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

Download URL foca-0.18.0-py3-none-any.whl
Size 264.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e6381212f4dd39db2da7048ac175065c4a783ebb9ebe3a49dfd352accd6b9225
BLAKE2b-256 checksum
How to use checksums
743d59059968ccf18ca1d23110d4ce2bc3b17d010b3906ef3419c763cb9086e1
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 Oct 27, 2026.

Transparency log

Security for foca 0.18.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.18.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 27, 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