An implementation of STAC API based on the FastAPI framework and using the pgstac backend.
Project description
stac-fastapi-pgstac
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 |
| >=4.0 | >=0.8,<0.10 |
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 at the API level, set the USE_API_HYDRATE environment variable to true. If false (default) the hydration will be done in the database.
| use_api_hydrate (API) | nohydrate (PgSTAC) | Hydration |
|---|---|---|
| False | False | PgSTAC |
| True | True | API |
Migrations
There is a Python utility as part of PgSTAC (pypgstac) that includes a migration utility. To use:
pypgstac migrate
Development
Install the packages in editable mode:
We recommand using uv as project manager for development.
See https://docs.astral.sh/uv/getting-started/installation/ for installation
uv sync --dev
To run the tests:
uv run pytest
Contributing
See CONTRIBUTING for detailed contribution instructions.
Releasing
See RELEASING.md.
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stac_fastapi_pgstac-6.2.2.tar.gz.
File metadata
- Download URL: stac_fastapi_pgstac-6.2.2.tar.gz
- Upload date:
- Size: 22.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdefccbcadb5c1247c545ac92095bae6c06fc6a307b73849c7848eaa368cae69
|
|
| MD5 |
94d2507755c76f8730aafe67b9034c13
|
|
| BLAKE2b-256 |
b84d8c2c19d7516c877d0ea511b666dcfaccdd0a29e3dc16eae05d6b5919eba8
|
File details
Details for the file stac_fastapi_pgstac-6.2.2-py3-none-any.whl.
File metadata
- Download URL: stac_fastapi_pgstac-6.2.2-py3-none-any.whl
- Upload date:
- Size: 26.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f2d044beefe6b2fd8882607c50951c57400d8f77e7d0fbb37118bffcad08feb
|
|
| MD5 |
829a4a10d77ffe29fed041ba85955f3f
|
|
| BLAKE2b-256 |
0983aedffbd2ee320e2fe4c24c60b2d5cc5071aba29c27c8253b2990e7a783f2
|