Skip to content

Commit 40b9d1b

Browse files
authored
Merge pull request #483 from joshfix/collections-post
Rework API examples page
2 parents 24c13f6 + df93e40 commit 40b9d1b

File tree

1 file changed

+76
-29
lines changed

1 file changed

+76
-29
lines changed

api-spec/examples.md

+76-29
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,84 @@
33
A STAC API supports both GET and POST requests. It is best to use POST when using the intersects query for two reasons:
44

55
1. the size limit for a GET request is less than that of POST, so if a complex geometry is used GET may fail.
6-
2. The parameters for a GET request must be escaped properly, making it more difficult to construct when using JSON parameters (such as intersect)
6+
2. The parameters for a GET request must be escaped properly, making it more difficult to construct when using JSON
7+
parameters (such as intersect)
78

89
## Core examples
910

11+
Requests all the items in the collection that is in New Zealand:
12+
1013
```
11-
GET /collections/{name}/items?bbox=160.6,-55.95,-170,-25.89
14+
GET /stac/search?bbox=160.6,-55.95,-170,-25.89
1215
```
1316

14-
Requests all the data in the collection that is in New Zealand. The filtering is made to be compatible with the STAC API,
15-
and the two specs seek to share the general query and filtering patterns. The key difference is that a STAC search endpoint
16-
will do cross collection search. A typical WFS will have multiple collections, and each will just offer search for its particular
17-
collection.
17+
Request all the items in `mycollection` that is in New Zealand:
1818

19-
Request all the data in mycollection that is in New Zealand:
19+
```
20+
GET /stac/search/items?bbox=160.6,-55.95,-170,-25.89&collections=mycollection
21+
```
22+
23+
Request 100 items in `mycollection` from New Zealand:
2024

2125
```
22-
GET /collections/mycollection/items?bbox=160.6,-55.95,-170,-25.89
26+
GET /stac/search?bbox=160.6,-55.95,-170,-25.89&limit=100&collections=mycollection
2327
```
2428

25-
Request 100 results in mycollection from New Zealand:
29+
Request all the items in `mycollection` that is in New Zealand from January 1st, 2019:
2630

2731
```
28-
GET /collections/mycollection/items?bbox=160.6,-55.95,-170,-25.89&limit=100
32+
GET /stac/search?bbox=160.6,-55.95,-170,-25.89&time=2019-01-01&collections=mycollection
33+
```
34+
35+
Request 100 items in `mycollection` or `yourcollection` that is in New Zealand from January 1st, 2019:
36+
37+
```
38+
GET /stac/search?bbox=160.6,-55.95,-170,-25.89&time=2019-01-01&limit=100&collections=mycollection,yourcollection
2939
```
3040

31-
Request results 101-200 in mycollection from New Zealand:
41+
Request all the items in any collection that is in New Zealand from January 1st, 2019:
3242

3343
```
34-
GET /collections/mycollection/items?bbox=160.6,-55.95,-170,-25.89&page=2&limit=100
44+
GET /stac/search?bbox=160.6,-55.95,-170,-25.89&time=2019-01-01
3545
```
3646

37-
Request all the data in mycollection that is in New Zealand from January 1st, 2019:
47+
Request all the items in any collection that is in New Zealand and has the id `1` or `2`:
3848

3949
```
40-
GET /collections/mycollection/items?bbox=160.6,-55.95,-170,-25.89&time=2019-01-01
50+
GET /stac/search?bbox=160.6,-55.95,-170,-25.89&time=2019-01-01&ids=1,2
4151
```
4252

43-
Request all the data in mycollection from between January 1st and April 1st, 2019:
53+
Request 100 items in `mycollection` or `yourcollection` that is in New Zealand and has the id `1` or `2`:
4454

4555
```
46-
GET /collections/mycollection/items?time=2019-01-01/2019-04-01
56+
GET /stac/search?bbox=160.6,-55.95,-170,-25.89&time=2019-01-01&limit=100&collections=mycollection,yourcollection&ids=1,2
57+
```
58+
59+
```
60+
POST /stac/search
61+
```
62+
63+
Body:
64+
```json
65+
{
66+
"bbox": [160.6, -55.95, -170, -25.89],
67+
"time": "2019-01-01",
68+
"limit": 100,
69+
"collections": ["mycollection", "yourcollection"],
70+
"ids": ["1", "2"]
71+
}
72+
```
73+
74+
Request all the items in `mycollection` from between January 1st and April 1st, 2019:
75+
76+
```
77+
GET /stac/search?time=2019-01-01/2019-04-01&collections=mycollection
4778
```
4879

4980
Request all catalog items it has that are from the second half of March, 2018 and that intersect with this area:
5081

5182
```
52-
POST /collections/mycollection/items
83+
POST /stac/search
5384
```
5485

5586
Body:
@@ -68,7 +99,7 @@ _Map © OpenStreetMap contributors_
6899
To specify a time range, use the interval syntax.
69100

70101
```
71-
POST /collections/mycollection/items
102+
POST /stac/search
72103
```
73104

74105
```json
@@ -91,11 +122,30 @@ If time is a period without a start or end date, the end date is assigned to "no
91122

92123
`P1Y2M10DT2H30M` is the same as `"P1Y2M10DT2H30M/" + new Date().toISOString()`
93124

125+
## Querying the collections endpoint
126+
127+
The collections endpoint does support the following query parameters to remain in alignment with WFS3: `time`, `bbox`,
128+
and `limit`. Due to the limited parameter support, it is recommended to use the `/stac/search` endpoint for dynamic
129+
STAC queries. Some STAC implementations may choose to provide support for the full superset of STAC query parameters
130+
to the collections endpoint, where the collection ID in the path variable is used as the single value in the
131+
`collections` query parameter array in order to ensure the results are limited to that collection. This is purely
132+
optional and neither required nor a recommendation.
133+
134+
Request 100 items in `mycollection` from New Zealand using the collections endpoint:
135+
136+
```
137+
GET /collections/mycollection/items?bbox=160.6,-55.95,-170,-25.89&limit=100
138+
```
139+
140+
Note that the collections endpoint _only_ supports HTTP GET. HTTP POST requests are not supported.
141+
94142
## Extension examples
95143

96-
The API Extensions allow for more sophisticated searching, such as the ability to search by geometries and searching on specific Item properties.
144+
The API Extensions allow for more sophisticated searching, such as the ability to search by geometries and searching on
145+
specific Item properties.
97146

98-
Use the *[Query](extensions/query/README.md)* extension to search for any data falling within a specific geometry collected between Jan 1st and May 1st, 2019:
147+
Use the *[Query](extensions/query/README.md)* extension to search for any items falling within a specific geometry
148+
collected between Jan 1st and May 1st, 2019:
99149

100150
```
101151
POST /stac/search
@@ -106,15 +156,12 @@ Body:
106156
{
107157
"limit": 100,
108158
"intersects": {
109-
"type": "Feature",
110-
"geometry": {
111-
"type": "Polygon",
112-
"coordinates": [[
113-
[-77.08248138427734, 38.788612962793636], [-77.01896667480469, 38.788612962793636],
114-
[-77.01896667480469, 38.835161408189364], [-77.08248138427734, 38.835161408189364],
115-
[-77.08248138427734, 38.788612962793636]
116-
]]
117-
}
159+
"type": "Polygon",
160+
"coordinates": [[
161+
[-77.08248138427734, 38.788612962793636], [-77.01896667480469, 38.788612962793636],
162+
[-77.01896667480469, 38.835161408189364], [-77.08248138427734, 38.835161408189364],
163+
[-77.08248138427734, 38.788612962793636]
164+
]]
118165
},
119166
"time": "2019-01-01/2019-05-01"
120167
}

0 commit comments

Comments
 (0)