Skip to content

geobeyond/fastgeoapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

fastgeoapi

A modern, high-performance geospatial API framework that extends pygeoapi with authentication, authorization, and security features using FastAPI, OpenID Connect, and Open Policy Agent (OPA) ๐Ÿ—บ๏ธ๐Ÿ”’.

pygeoapi logo ย ย ย ย  Open Policy Agent logo

PyPI Python License

Documentation Tests Contract Tests ZAP Scan Codecov

pre-commit Ruff uv

Architecture

This diagram gives an overview of the basic architecture:

general architecture

Features

๐Ÿ” Security & Authentication

  • OpenID Connect (OIDC) Integration - OAuth2/JWT Bearer token authentication with JWKS support
  • API Key Authentication - Flexible API key-based authentication for programmatic access
  • Open Policy Agent (OPA) - Policy-based authorization with fine-grained access control
  • Multi-scheme Support - Seamlessly switch between authentication methods based on your needs

๐Ÿš€ Performance & Modern Stack

  • FastAPI Framework - High-performance async API built on Starlette and Pydantic
  • Async I/O - Non-blocking operations for better scalability
  • Modern Python - Python 3.12+ with type hints and modern language features
  • Fast Dependency Management - UV-based tooling for lightning-fast installations

๐Ÿ—บ๏ธ Geospatial API Standards

  • OGC API Compliance - Full support for OGC API - Features, Processes, and more
  • OpenAPI Integration - Auto-generated, security-enhanced OpenAPI specifications
  • Geospatial Data Access - Seamless access to vector and raster geospatial data
  • pygeoapi Extension - Extends vanilla pygeoapi with enterprise-ready security

๐Ÿ›ก๏ธ Security Testing & Quality

  • Contract Testing - Automated OpenAPI contract validation with Schemathesis
  • Security Scanning - OWASP ZAP integration for continuous security testing
  • Pre-commit Hooks - Code quality checks with Ruff formatting and linting
  • Comprehensive Test Coverage - Full test suite with pytest and coverage reporting

Requirements

  • pygeoapi
  • fastapi-opa
  • An OpenID Connect provider (Keycloak, WSO2, etc)
  • Open Policy Agent (OPA)

Installation

You can install fastgeoapi via pip from PyPI:

pip install fastgeoapi

Development

Prerequisites

Install UV - a fast Python package installer and resolver:

macOS / Linux:

curl -sSf https://install.ultraviolet.dev | sh

Windows (PowerShell):

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Setup

After cloning the repository, use UV to install dependencies:

git clone https://github.com/geobeyond/fastgeoapi.git
cd fastgeoapi
uv sync

This automatically:

  • Creates a virtual environment in .venv
  • Installs all required dependencies including git-based packages (pygeoapi, pygeofilter, fencer)
  • Sets up fastgeoapi in development mode

Activate the Virtual Environment

macOS / Linux:

source .venv/bin/activate

Windows (PowerShell):

.venv\Scripts\Activate.ps1

Running fastgeoapi

Once Keycloak and OPA have been started, configure the required environment variables:

export PYGEOAPI_CONFIG=pygeoapi-config.yml
export PYGEOAPI_OPENAPI=pygeoapi-openapi.yml
export FASTGEOAPI_CONTEXT='/geoapi'

Start fastgeoapi in development mode:

uv run fastapi run app/main.py --app app --host 0.0.0.0 --port 5000 --reload

Common UV Commands

# Update dependencies
uv sync --upgrade

# View installed packages
uv pip list

# Install a new package
uv pip install package-name

# Install dev dependencies
uv pip install --group dev

For more details, see uv.md.

Usage

Please see the Command-line Reference for details.

Please have a look at the docker-compose.yml file under scripts/iam to start the stack with Keycloak and Open Policy Agent locally. There is a README.md file that explains how to use it.

The file scripts/iam/keycloak/realm-export.json can be used to import an already configured realm into Keycloak.

The files under scripts/postman can be used to setup Postman with a configuration that is ready to perform the requests for the whole stack.

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the MIT license, fastgeoapi is free and open-source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Credits

This project was generated from @cjolowicz's Hypermodern Python Cookiecutter template.

About

A FastAPI application wrapping pygeoapi as a library with security batteries included

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 6