Skip to content

Commit f74ecfb

Browse files
Merge pull request #57 from developmentseed/feat/add-items-env-settings
add: env settings to configure items search
2 parents 7fc869b + d42cebb commit f74ecfb

7 files changed

Lines changed: 45 additions & 15 deletions

File tree

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
repos:
22
- repo: https://github.com/abravalheri/validate-pyproject
3-
rev: v0.24
3+
rev: v0.25
44
hooks:
55
- id: validate-pyproject
66

77
- repo: https://github.com/PyCQA/isort
8-
rev: 5.12.0
8+
rev: 8.0.1
99
hooks:
1010
- id: isort
1111
language_version: python
1212

1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.8.4
14+
rev: v0.15.9
1515
hooks:
1616
- id: ruff
1717
args: ["--fix"]
1818
- id: ruff-format
1919

2020
- repo: https://github.com/pre-commit/mirrors-mypy
21-
rev: v1.11.2
21+
rev: v1.20.0
2222
hooks:
2323
- id: mypy
2424
language_version: python

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## [Unreleased]
44

5+
## [2.0.1] - 2026-04-07
6+
7+
* add: env settings to configure MaxItems and ItemsPerPage options for STAC API Backend
8+
- `TITILER_STACAPI_ITEMS_PER_PAGE`: set number of items `per-page` returned for Search request (defaults to 10)
9+
- `TITILER_STACAPI_MAX_ITEMS`: set max items returned by a Search request (defaults to 100)
10+
511
## [2.0.0] - 2026-03-16
612

713
* change: titiler-* requirements to >=2.0,<2.1

titiler/stacapi/backend.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323

2424
from titiler.stacapi.dependencies import APIParams, Search
2525
from titiler.stacapi.reader import Item, SimpleSTACReader
26-
from titiler.stacapi.settings import CacheSettings, RetrySettings
26+
from titiler.stacapi.settings import CacheSettings, ItemsSettings, RetrySettings
2727

2828
cache_config = CacheSettings()
2929
retry_config = RetrySettings()
30+
items_config = ItemsSettings()
3031

3132
ttl_cache = TTLCache(maxsize=cache_config.maxsize, ttl=cache_config.ttl) # type: ignore
3233

@@ -138,8 +139,8 @@ def get_assets(
138139
**self.input,
139140
"method": "GET" if self.input.get("filter") else "POST",
140141
"sortby": sortby,
141-
"limit": limit or 10,
142-
"max_items": max_items or 100,
142+
"limit": limit or items_config.items_per_page,
143+
"max_items": max_items or items_config.max_items,
143144
}
144145
fields = fields or ["assets", "id", "bbox", "collection"]
145146

titiler/stacapi/dependencies.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
from urllib3 import Retry
1616

1717
from titiler.core.dependencies import DefaultDependency
18-
from titiler.stacapi.settings import CacheSettings, RetrySettings
18+
from titiler.stacapi.settings import CacheSettings, ItemsSettings, RetrySettings
1919

2020
ResponseType = Literal["json", "html"]
2121

2222
cache_config = CacheSettings()
2323
retry_config = RetrySettings()
24+
items_config = ItemsSettings()
2425

2526

2627
class APIParams(TypedDict):
@@ -286,12 +287,16 @@ class STACAPIExtensionParams(DefaultDependency):
286287
] = None
287288
limit: Annotated[
288289
int | None,
289-
Query(description="Limit the number of items per page search (default: 10)"),
290-
] = 10
290+
Query(
291+
description=f"Limit the number of items per page search (default: {items_config.items_per_page})"
292+
),
293+
] = None
291294
max_items: Annotated[
292295
int | None,
293-
Query(description="Limit the number of total items (default: 100)"),
294-
] = 100
296+
Query(
297+
description=f"Limit the number of total items (default: {items_config.max_items})"
298+
),
299+
] = None
295300

296301
def __post_init__(self):
297302
"""Post Init."""

titiler/stacapi/factory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ def get_layer_from_collections( # noqa: C901
191191
layer["bbox"] = tuple(spatial_extent.bboxes[0])
192192

193193
if supported_tms:
194-
tilematrixsets: dict[str, tuple[int, int] | None] = {
195-
tms_id: None for tms_id in supported_tms.list()
196-
}
194+
tilematrixsets: dict[str, tuple[int, int] | None] = dict.fromkeys(
195+
supported_tms.list()
196+
)
197197
for tms_id, zooms in tilematrixsets.items():
198198
if zooms := render_tilematrixsets.get(tms_id):
199199
tilematrixsets[tms_id] = zooms

titiler/stacapi/settings.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,16 @@ class STACAPISettings(BaseSettings):
8383
"env_file": ".env",
8484
"extra": "ignore",
8585
}
86+
87+
88+
class ItemsSettings(BaseSettings):
89+
"""STAC API Items settings"""
90+
91+
max_items: int = 100
92+
items_per_page: int = 10
93+
94+
model_config = {
95+
"env_prefix": "TITILER_STACAPI_",
96+
"env_file": ".env",
97+
"extra": "ignore",
98+
}

uv.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)