You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Pydantic](https://pydantic-docs.helpmanual.io/) models for [STAC](https://github.com/radiantearth/stac-spec) Catalogs, Collections, Items, and the [STAC API](https://github.com/radiantearth/stac-api-spec) spec. Initially developed by [arturo-ai](https://github.com/arturo-ai).
1
+
# stac-pydantic
2
+
3
+
[](https://github.com/stac-utils/stac-pydantic/actions/workflows/cicd.yml)
4
+
5
+
[Pydantic](https://pydantic-docs.helpmanual.io/) models for [STAC](https://github.com/radiantearth/stac-spec) Catalogs, Collections, Items, and the [STAC API](https://github.com/radiantearth/stac-api-spec) spec.
6
+
Initially developed by [arturo-ai](https://github.com/arturo-ai).
7
+
8
+
The main purpose of this library is to provide reusable request/response models for tools such as [fastapi](https://fastapi.tiangolo.com/).
9
+
For more comprehensive schema validation and robust extension support, use [pystac](https://github.com/stac-utils/pystac).
3
10
4
11
## Installation
5
-
```
12
+
13
+
```shell
6
14
pip install stac-pydantic
7
15
```
8
16
9
17
For local development:
10
-
```
11
-
pip install -e .["dev"]
18
+
19
+
```shell
20
+
pip install -e '.[dev,lint]'
12
21
```
13
22
14
-
| stac-pydantic | STAC Version |
15
-
|---------------|--------------|
16
-
| 1.1.x | 0.9.0 |
17
-
| 1.2.x | 1.0.0-beta.1 |
18
-
| 1.3.x | 1.0.0-beta.2 |
19
-
| 2.0.x | 1.0.0 |
23
+
| stac-pydantic | STAC Version | STAC API Version | Pydantic Version |
STAC defines many extensions which let the user customize the data in their catalog. `stac-pydantic.extensions.validate_extensions` will validate a `dict`, `Item`, `Collection` or `Catalog` against the schema urls provided in the `stac_extensions` property:
92
+
93
+
STAC defines many extensions which let the user customize the data in their catalog. `stac-pydantic.extensions.validate_extensions` will validate a `dict`, `Item`, `Collection` or `Catalog` against the schema urls provided in the `stac_extensions` property:
The complete list of current STAC Extensions can be found [here](https://stac-extensions.github.io/).
108
121
109
122
#### Vendor Extensions
123
+
110
124
The same procedure described above works for any STAC Extension schema as long as it can be loaded from a public url.
111
125
126
+
### STAC API
127
+
128
+
The [STAC API Specs](https://github.com/radiantearth/stac-api-spec) extent the core STAC specification for implementing dynamic catalogs. STAC Objects used in an API context should always import models from the `api` subpackage. This package extends
129
+
Catalog, Collection, and Item models with additional fields and validation rules and introduces Collections and ItemCollections models and Pagination/ Search Links.
130
+
It also implements models for defining ItemSeach queries.
131
+
132
+
```python
133
+
from stac_pydantic.api import Item, ItemCollection
Most STAC extensions are namespaced with a colon (ex `eo:gsd`) to keep them distinct from other extensions. Because
114
181
Python doesn't support the use of colons in variable names, we use [Pydantic aliasing](https://pydantic-docs.helpmanual.io/usage/model_config/#alias-generator)
115
182
to add the namespace upon model export. This requires [exporting](https://pydantic-docs.helpmanual.io/usage/exporting_models/)
116
-
the model with the `by_alias = True` parameter. A convenience method (``to_dict()``) is provided to export models with
117
-
extension namespaces:
183
+
the model with the `by_alias = True` parameter. Export methods (`model_dump()` and `model_dump_json()`) for models in this library have `by_alias` and `exclude_unset` st to `True` by default:
0 commit comments