Skip to content

jaysnm/stac-fastapi

 
 

Repository files navigation

FastAPI implemention of the STAC API spec.

Test Package version License


Documentation: https://stac-utils.github.io/stac-fastapi/

Source Code: https://github.com/stac-utils/stac-fastapi


Python library for building a STAC compliant FastAPI application. The project is split up into several namespace packages:

  • stac_fastapi.api: An API layer which enforces the stac-api-spec.
  • stac_fastapi.extensions: Abstract base classes for STAC API extensions and third-party extensions.
  • stac_fastapi.types: Shared types and abstract base classes used by the library.

Backends

  • stac_fastapi.sqlalchemy: Postgres backend implementation with sqlalchemy.
  • stac_fastapi.pgstac: Postgres backend implementation with PGStac.

stac-fastapi was initially developed by arturo-ai.

Installation

# Install from pypi.org
pip install stac-fastapi.api stac-fastapi.types stac-fastapi.extensions

# Install a backend of your choice
pip install stac-fastapi.sqlalchemy
# or
pip install stac-fastapi.pgstac

#/////////////////////
# Install from sources

git clone https://github.com/stac-utils/stac-fastapi.git && cd stac-fastapi
pip install \
  -e stac_fastapi/api \
  -e stac_fastapi/types \
  -e stac_fastapi/extensions

# Install a backend of your choice
pip install -e stac_fastapi/sqlalchemy
# or
pip install -e stac_fastapi/pgstac

Local Development

Use docker-compose to deploy the application, migrate the database, and ingest some example data:

docker-compose build
docker-compose up

# You can also launch application with specific backend (PGSTac or sqlalchemy)
docker-compose up app-sqlalchemy
# or
docker-compose up app-pgstac

For local development it is often more convenient to run the application outside of docker-compose:

make docker-run

Note to Docker for Windows users

You'll need to enable experimental features on Docker for Windows in order to run the docker-compose, due to the "--platform" flag that is required to allow the project to run on some Apple architectures. To do this, open Docker Desktop, go to settings, select "Docker Engine", and modify the configuration JSON to have "experimental": true.

Testing

The database container provided by the docker-compose stack must be running. Run all tests:

make test

Run individual tests by running pytest within the docker container:

make docker-shell
$ pytest -v

About

STAC API implementation with FastAPI.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 96.6%
  • Shell 2.3%
  • Other 1.1%