Connect titiler to STAC APIs
Documentation: https://developmentseed.org/titiler-stacapi/
Source Code: https://github.com/developmentseed/titiler-stacapi
To install from PyPI and run:
# Make sure you have pip up to date
python -m pip install -U pip
python -m pip install titiler.stacapiTo install from sources and run for development:
We recommand using uv as project manager for development.
See https://docs.astral.sh/uv/getting-started/installation/ for installation
git clone https://github.com/developmentseed/titiler-stacapi.git
cd titiler-stacapi
uv syncYou'll need to have TITILER_STACAPI_STAC_API_URL variables set in your environment pointing to your STAC API service.
export TITILER_STACAPI_STAC_API_URL=https://api.stac
uv run --extra server uvicorn titiler.stacapi.main:app --port 8000
$ git clone https://github.com/developmentseed/titiler-stacapi.git
$ cd titiler-stacapi
$ export TITILER_STACAPI_STAC_API_URL=https://api.stac
$ docker-compose up --build api
It runs titiler.stacapi using Uvicorn web server.
titiler-stacapi makes extensive use of the Render extension, specifically at the Collection level.
By using the render's metadata, the /wmts endpoint (from the OGCEndpointsFactory factory) can populate a set of layers returned by the GetCapabilities service.
Install the optional metrics extra and enable it:
python -m pip install "titiler.stacapi[metrics]"
export TITILER_STACAPI_API_METRICS_ENABLED=TRUEThe published Docker image already ships the metrics extra; with the default single worker
(WEB_CONCURRENCY=1) only the environment variable is needed. For more workers, see
Multi-worker deployments.
Once enabled, /metrics is available on startup and records:
titiler_stacapi_http_requests_total{operation,method,status}titiler_stacapi_http_request_duration_seconds{operation,method}
operation is a low-cardinality label derived from the route template (never from the
requested URL, so collection IDs, item IDs and layer names do not end up in labels):
| operation | routes |
|---|---|
landing, conformance, docs |
/, /conformance, /api, /api.html |
tiles |
.../tiles, .../tiles/{tileMatrixSetId}/... (collection and item) |
point, bbox, feature, preview |
.../point/..., .../bbox/..., .../feature..., .../preview... |
info, statistics, assets |
.../info[.geojson], .../[asset_]statistics, .../assets (incl. collection tiles/.../assets, point/.../assets, bbox/.../assets) |
tilejson, map |
.../tilejson.json, .../map.html |
wmts, wms, layers |
/wmts, .../WMTSCapabilities.xml, /wms, /layers/... |
tms, algorithms, colormaps |
/tileMatrixSets..., /algorithms..., /colorMaps... |
other, unknown |
any other route / no matched route |
status is grouped (2xx, 3xx, 4xx, 5xx). method is one of GET, HEAD, POST,
PUT, PATCH, DELETE, OPTIONS, or other for any non-standard method. CORS preflights are counted under the
operation of the route they target, with method="OPTIONS". /healthz and
the scrape endpoint are excluded from request counters. Untemplated paths (for example bare
404s) are also ignored.
With TITILER_STACAPI_API_METRICS_ENABLED left at its default (FALSE), /metrics is not
registered even if the extra is installed.
For multi-worker deployments (for example uvicorn --workers N, or Gunicorn as used by the
Docker image with WEB_CONCURRENCY > 1), set PROMETHEUS_MULTIPROC_DIR to an existing
writable directory before the application is imported, and clear that directory before
each server start.
export PROMETHEUS_MULTIPROC_DIR=/tmp/titiler-stacapi-prometheus
mkdir -p "$PROMETHEUS_MULTIPROC_DIR"
rm -rf "$PROMETHEUS_MULTIPROC_DIR"/*With Gunicorn, also mark workers dead on exit so stale metric files are cleaned up:
from prometheus_client import multiprocess
def child_exit(server, worker):
multiprocess.mark_process_dead(worker.pid)Custom apps can enable the same instrumentation:
from titiler.stacapi.metrics import instrument_app
instrument_app(app) # or instrument_app(app, endpoint="/custom-metrics")If the custom app also uses CacheControlMiddleware, add the scrape endpoint to its
exclude_path so metrics responses are never cached.
See CONTRIBUTING.md
See LICENSE
See contributors for a listing of individual contributors.
See CHANGES.md.

