Skip to main content

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

Project description

FastAPI implemention of the STAC API spec using PGStac

Test Package version Downloads


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

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


Stac FastAPI using the PGStac backend.

PGStac is a separately managed PostgreSQL database that is designed for enhanced performance to be able to scale Stac FastAPI to be able to efficiently handle hundreds of millions of records. PGStac automatically includes indexes on Item id, Collection id, Item Geometry, Item Datetime, and an Index for equality checks on any key in Item Properties. Additional indexes may be added to Item Properties to speed up the use of order, <, <=, >, and >= queries.

Stac FastAPI acts as the HTTP interface validating any requests and data that is sent to the PGStac backend and adds in Link items on data return relative to the service host. 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.

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.

stac-fastapi pgstac was initially added to stac-fastapi by developmentseed.

Installation

git clone https://github.com/stac-utils/stac-fastapi.git
cd stac-fastapi
pip install -e \
    stac_fastapi/api[dev] \
    stac_fastapi/types[dev] \
    stac_fastapi/extensions[dev] \
    stac_fastapi/pgstac[dev,server]

Settings

To configure PGStac stac-fastapi 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

PGStac is an external project and the 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 at bitner/pgstac:[version] that has the full database already set up for PGStac.

There is also a python utility as part of PGStac (pypgstac) that includes a migration utility. The pgstac version required by stac-fastapi/pgstac is pinned by using the pinned version of pypgstac in the setup file.

In order to migrate database versions you can use the migration utility:

pypgstac migrate

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-2.4.0.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

stac_fastapi.pgstac-2.4.0-py3-none-any.whl (30.9 kB view details)

Uploaded Python 3

File details

Details for the file stac-fastapi.pgstac-2.4.0.tar.gz.

File metadata

  • Download URL: stac-fastapi.pgstac-2.4.0.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for stac-fastapi.pgstac-2.4.0.tar.gz
Algorithm Hash digest
SHA256 cc77629e43d4fa7bab9d13f3b5c7c3417c0508096579fc627d3a7bc7cb187ab3
MD5 c35057a4fb32bbbe2d193b7e6f5bd426
BLAKE2b-256 afec18a2f5dddf677485e1ac9dbdce214eec7dfc9c3c8f08cdde0a2b26a3e159

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for stac_fastapi.pgstac-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10140213c23153d4eb72f583d5414e986386ceecaa4bcae205aae4a0265839a8
MD5 ff6952e29ea784af43fe18c1dc0f63ee
BLAKE2b-256 ebc98e80dcadddd5c6fd8237b4b0abff9ef66aebc3c01f99292c4bf4d60597f9

See more details on using hashes here.

Provenance

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