Skip to content

Example HTTP API

Routes, tile path format, style parameters, and response behavior.

The HTTP API belongs to examples/serve.rs; it is not part of the library’s dependency surface.

Routes

Method and pathPurpose
GET /tiles/{tms}/{z}/{x}/{y}.{ext}Render a tile from the selected single COG.
GET /mosaic/tiles/{tms}/{z}/{x}/{y}.{ext}Render a tile from the configured mosaic or STAC source.
GET /datasetsList local TIFF files discovered under data/.
GET /cache/statsReturn decoded-block cache statistics.
GET /formatsReturn output formats compiled into the server.
GET /boundsReturn bounds used by the example viewers.
GET, HEAD /data/{name}Serve a discovered local TIFF with range support.

Supported TMS names are WebMercatorQuad and WorldCRS84Quad. Supported extensions are png, feature-gated webp, and feature-gated jpg/jpeg.

Style parameters

ParameterRepeatDefault or exampleMeaning
bidxyesbidx=1&bidx=2&bidx=31-indexed source-band selection.
expressionno(b5-b4)/(b5+b4)Arithmetic expression producing one derived band.
rescaleyes0,3000Explicit per-band min,max range; highest stretch priority.
stretchnominmax, percent, stddevAutomatic stretch mode.
pcno2,98Percentile cut used by stretch=percent.
sigmano2.0Standard-deviation multiplier.
nodatanonan, inf, -inf, or floatOverride the dataset nodata value.
colormap_namenoviridisBuilt-in single-band color ramp.
color_formulanogamma RGB 1.5Supported rio-color operation sequence.
resamplingnonearestSource read or resize kernel.
reprojectnonearestWarp-time resampling kernel.
tilesizeno256One of 64, 128, 256, 512, or 1024.
formatnopngOptional format assertion; must agree with the path extension.

Resampling kernels are nearest, bilinear, cubic, cubic_spline, lanczos, and average. Average computes a box mean for downsampling and uses nearest behavior when upsampling.

The mosaic tile route additionally accepts pixel_selection=first, highest, lowest, mean, or median. The default is first.

Responses

  • 200 OK returns encoded image bytes.
  • 204 No Content means the coordinate is valid but fully outside the source dataset or projection domain.
  • Invalid style values and malformed coordinates return a client error with a structured library error behind it.

The default output size is 256×256, chosen for broad XYZ-client compatibility.