Skip to content

Commit 05f1cd6

Browse files
committed
get collection directly from endpoint with APIs
1 parent 342be82 commit 05f1cd6

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111
### Changed
1212
- Update min PySTAC version to 1.2
1313
- Default page size limit set to 100 rather than relying on the server default
14+
- Fetch single collection directly from endpoint in API rather than iterating through children (Issue #114)[https://github.com/stac-utils/pystac-client/issues/114]
1415

1516
### Added
1617

pystac_client/client.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,14 @@ def get_collection(self, collection_id: str) -> CollectionClient:
8787
Returns:
8888
CollectionClient: A STAC Collection
8989
"""
90-
for col in self.get_collections():
91-
if col.id == collection_id:
92-
return col
90+
if self._stac_io.conforms_to(ConformanceClasses.COLLECTIONS):
91+
url = f"{self.get_self_href()}/collections/{collection_id}"
92+
collection = CollectionClient.from_dict(self._stac_io.read_json(url))
93+
return collection
94+
else:
95+
for col in self.get_collections():
96+
if col.id == collection_id:
97+
return col
9398

9499
def get_collections(self) -> Iterable[CollectionClient]:
95100
""" Get Collections in this Catalog

0 commit comments

Comments
 (0)