Skip to main content

An implementation of STAC API based on the FastAPI framework and using the pgstac backend.

Project description

stac-fastapi-pgstac

GitHub Workflow Status PyPI Documentation License

FastAPI

PgSTAC backend for stac-fastapi, the FastAPI implementation of the STAC API spec

Overview

stac-fastapi-pgstac is an HTTP interface built in FastAPI. It validates requests and data sent to a PgSTAC backend, and adds links to the returned data. All other processing and search is provided directly using PgSTAC procedural sql / plpgsql functions on the database. PgSTAC stores all collection and item records as jsonb fields exactly as they come in allowing for any custom fields to be stored and retrieved transparently.

PgSTAC version

stac-fastapi-pgstac depends on pgstac database schema and pypgstac python package.

stac-fastapi-pgstac Version pgstac
2.5 >=0.7,<0.8
3.0 >=0.8,<0.9

Usage

PgSTAC is an external project and may be used by multiple front ends. For Stac FastAPI development, a Docker image (which is pulled as part of the docker-compose) is available via the Github container registry. The PgSTAC version required by stac-fastapi-pgstac is found in the setup file.

Sorting

While the STAC Sort Extension is fully supported, PgSTAC is particularly enhanced to be able to sort by datetime (either ascending or descending). Sorting by anything other than datetime (the default if no sort is specified) on very large STAC repositories without very specific query limits (ie selecting a single day date range) will not have the same performance. For more than millions of records it is recommended to either set a low connection timeout on PostgreSQL or to disable use of the Sort Extension.

Hydration

To configure stac-fastapi-pgstac to hydrate search result items in the API, set the USE_API_HYDRATE environment variable to true or explicitly set the option in the PGStac Settings object.

Migrations

There is a Python utility as part of PgSTAC (pypgstac) that includes a migration utility. To use:

pypgstac migrate

Contributing

See CONTRIBUTING for detailed contribution instructions.

To install:

git clone https://github.com/stac-utils/stac-fastapi-pgstac
cd stac-fastapi-pgstac
python -m pip install -e ".[dev,server,docs]"

To test:

make test

Use Github Pull Requests to provide new features or to request review of draft code, and use Issues to report bugs or request new features.

Documentation

To build the docs:

make docs

Then, serve the docs via a local HTTP server:

mkdocs serve

History

stac-fastapi-pgstac was initially added to stac-fastapi by developmentseed. In April of 2023, it was removed from the core stac-fastapi repository and moved to its current location (http://github.com/stac-utils/stac-fastapi-pgstac).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stac_fastapi_pgstac-3.0.1.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

stac_fastapi.pgstac-3.0.1-py3-none-any.whl (40.4 kB view details)

Uploaded Python 3

File details

Details for the file stac_fastapi_pgstac-3.0.1.tar.gz.

File metadata

  • Download URL: stac_fastapi_pgstac-3.0.1.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for stac_fastapi_pgstac-3.0.1.tar.gz
Algorithm Hash digest
SHA256 17af2adff89e03e64faa9a2d9acdc8f47522170dc2ccb19a123d61660f8babcc
MD5 0b32c70c455c16c615cec8ecba2aeb58
BLAKE2b-256 f0cc924d1f668ac8a2b4c6616ebb1ea4f7572b80bce946a761e92d8f694f1a40

See more details on using hashes here.

File details

Details for the file stac_fastapi.pgstac-3.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for stac_fastapi.pgstac-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 166f961ca5d374b28061d4c0355f9e360aaf98bd855490a710213f5741d46d97
MD5 82eedc709e903bc93d83e0c82939dd8a
BLAKE2b-256 753a39cfdbbb5932e9343f4d0c6f248e8b97fe4cec2e1a7c8fea6386fa53be1e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page