Skip to main content

titiler-stacapi

Connect titiler to STAC APIs

Test Package version Coverage License


Documentation: https://developmentseed.org/titiler-stacapi/

Source Code: https://github.com/developmentseed/titiler-stacapi


Installation

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.stacapi

To 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 sync

Launch

You'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

Using Docker

$ 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.

How it works

WMTS and the Render extension

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.

Prometheus metrics

Install the optional metrics extra and enable it:

python -m pip install "titiler.stacapi[metrics]"
export TITILER_STACAPI_API_METRICS_ENABLED=TRUE

The 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.

Multi-worker deployments

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

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.

Contribution & Development

See CONTRIBUTING.md

License

See LICENSE

Authors

See contributors for a listing of individual contributors.

Changes

See CHANGES.md.

Metadata

Release files for titiler-stacapi 2.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for titiler-stacapi 2.3.0
File Size Uploaded Provenance Actions
titiler_stacapi-2.3.0.tar.gz 43.1 kB With provenance Details for titiler_stacapi-2.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for titiler-stacapi 2.3.0
File Interpreter ABI Platform Actions
titiler_stacapi-2.3.0-py3-none-any.whl Python 3 none any Details for titiler_stacapi-2.3.0-py3-none-any.whl

Total release size: 91.7 kB

Release files / titiler_stacapi-2.3.0.tar.gz

Download URL titiler_stacapi-2.3.0.tar.gz
Size 43.1 kB
Tags Source
SHA-256 checksum
How to use checksums
17dff115bcd97eb5ae9708e86c59de4489c9760650d06ed5fdca9db68d738d72
BLAKE2b-256 checksum
How to use checksums
fbb1eba81a3f2c7f074fa099b57f799e8238636a21da04cc919e354d6b3d40bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / titiler_stacapi-2.3.0-py3-none-any.whl

Download URL titiler_stacapi-2.3.0-py3-none-any.whl
Size 48.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d7e67e0c36f6463763154aba69d330592e193f46ac36bcc2e6065fe33807eed
BLAKE2b-256 checksum
How to use checksums
438872e308cec2c94156cfc16376733359af6df8f0dd4e208763c3cd8f20b600
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for titiler-stacapi 2.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for titiler_stacapi-2.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page