Home
FastAPI implemention of the STAC API spec.
Documentation: https://stac-utils.github.io/stac-fastapi/
Source Code: stac-utils/stac-fastapi
Python library for building a STAC-compliant FastAPI application.
STAC stands for SpatioTemporal Asset Catalogs. The STAC specification is a common language to describe geospatial information, so it can more easily be worked with, indexed, and discovered.
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python based on standard Python type hints.
This projects aims to make it easier to create a STAC-compatible API, with many tools embed. No need to re-invent the wheel!
stac-fastapi was initially developed by arturo-ai.
Features¶
- STAC‑compliant FastAPI framework
- Modular packages and extensions
- Multiple backend integrations
- Model validation and types
Library packages¶
Namespaces¶
| Package | Description | Version |
|---|---|---|
| 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¶
In addition to the packages in this repository, a server implemention will also require the selection of a backend to connect with a database for STAC metadata storage. There are several different backend options, and each has their own repository.
| Backend | Code | Remarks |
|---|---|---|
| PostgreSQL + PostGIS + PgSTAC | stac-fastapi-pgstac | |
| Elasticsearch or OpenSearch | stac-fastapi-elasticsearch-opensearch | |
| MongoDB | stac-fastapi-mongo | |
| GeoParquet via stacrs | stac-fastapi-geoparquet | Experimental |
| DuckDB | stac-fastapi-duckdb | Experimental |
| PostgreSQL + PostGIS + SQLAlchemy | stac-fastapi-sqlalchemy | Abandoned in favor of stac-fastapi-pgstac |
Extensions¶
The STAC API specification offers an extension system, some of them are offered here to be ready-to-use in complement of your STAC FastAPI:
| Name | Description |
|---|---|
| Aggregation | Aggregation Extension to provide aggregated data over a search, rather than individual Item results |
| Bulk Transactions | Bulk Transaction extension allows efficient bulk insertion of items. |
| Collection Search | Collection Search for STAC APIs |
| Fields | The Fields Extensions describes a mechanism to include or exclude certain fields from a response. |
| Filter | The Filter extension provides an expressive mechanism for searching based on Item attributes. |
| Free text | This defines a new parameter, q that allows the user to perform free-text queries against the item properties. |
| Multi-tenant Catalogs | STAC API Extension to support Multi-Catalog hierarchies via a dedicated /catalogs endpoint. (Recursive Tree architecture). |
| Pagination | Though not strictly an extension, the chosen pagination will modify the form of the request object. |
| Query | The Query Extension adds a query parameter that allows additional filtering based on the properties of Item objects. |
| Sort | The Sort Extension adds the sortby parameter and exposes /sortables, /collections/{id}/sortables, and /collections-sortables endpoints for discovering sortable fields. |
| Transaction | The Transaction Extension supports the creation, editing, and deleting of items through POST, PUT, PATCH, and DELETE requests. |
Note
You can also create your own extensions! To do so, check out the Development & Contributing guide.
Get started¶
# Install core software from PyPI
python -m pip install stac-fastapi.types stac-fastapi.api stac-fastapi.extensions uvicorn
# Install a backend of your choice, here's PgSTAC
python -m pip install stac-fastapi.pgstac
# Launch the API
uvicorn stac_fastapi.pgstac.app:app --host 0.0.0.0 --port 8080
Your API is running on localhost:8080.
For more details, please see our get started guide.
Development & Contributing¶
See our Development & Contributing guide.
License¶
This project is licensed under the MIT License - see the LICENSE file for details.