Skip to content

Commit 7842836

Browse files
authored
Update README.md
1 parent d075a52 commit 7842836

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

docs/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,67 @@
11
# DuckDB HTTP Client Extension
22

33
Experimental HTTP Client Community Extension
4+
5+
### GET
6+
```sql
7+
D SET autoinstall_known_extensions=1; SET autoload_known_extensions=1;
8+
D WITH __input AS (
9+
SELECT
10+
http_get(
11+
'https://earth-search.aws.element84.com/v0/search')
12+
AS data
13+
),
14+
__features AS (
15+
SELECT
16+
unnest( from_json((data::JSON)->'features', '["json"]') )
17+
AS features
18+
FROM
19+
__input
20+
)
21+
SELECT
22+
features->>'id' AS id,
23+
features->'properties'->>'sentinel:product_id' AS product_id,
24+
concat(
25+
'T',
26+
features->'properties'->>'sentinel:utm_zone',
27+
features->'properties'->>'sentinel:latitude_band',
28+
features->'properties'->>'sentinel:grid_square'
29+
) AS grid_id,
30+
ST_GeomFromGeoJSON(features->'geometry') AS geom
31+
FROM
32+
__features
33+
;
34+
┌──────────────────────┬──────────────────────┬─────────┬──────────────────────────────────────────────────────────────────────────────────┐
35+
│ id │ product_id │ grid_id │ geom │
36+
varcharvarcharvarchar │ geometry │
37+
├──────────────────────┼──────────────────────┼─────────┼──────────────────────────────────────────────────────────────────────────────────┤
38+
│ S2B_55GDP_20241003… │ S2B_MSIL2A_2024100… │ T55GDP │ POLYGON ((146.7963024570636 -42.53859799130381, 145.7818492341335 -42.53284395… │
39+
│ S2B_55HEC_20241003… │ S2B_MSIL2A_2024100… │ T55HEC │ POLYGON ((146.9997932100229 -34.429312828654396, 146.9997955899612 -33.4390429… │
40+
│ S2B_55JHN_20241003… │ S2B_MSIL2A_2024100… │ T55JHN │ POLYGON ((149.9810192714723 -25.374826158099584, 149.9573295859729 -24.3845516… │
41+
│ S2B_15MWT_20230506… │ S2B_MSIL2A_2023050… │ T15MWT │ POLYGON ((-92.01266261624052 -2.357695714729873, -92.0560908879947 -2.35076658… │
42+
│ S2B_16PBT_20230506… │ S2B_MSIL2A_2023050… │ T16PBT │ POLYGON ((-88.74518736203468 11.690012668805194, -88.9516536515512 11.72635252… │
43+
│ S2B_16PCT_20230506… │ S2B_MSIL2A_2023050… │ T16PCT │ POLYGON ((-87.82703591176752 11.483638069337541, -88.8349824533826 11.70734355… │
44+
│ S2B_15PZP_20230506… │ S2B_MSIL2A_2023050… │ T15PZP │ POLYGON ((-89.24113885498912 11.784951995968179, -89.38831685490888 11.8080246… │
45+
│ S2B_16PET_20230506… │ S2B_MSIL2A_2023050… │ T16PET │ POLYGON ((-87.00017408768262 11.277451946475995, -87.00017438483464 11.7600349… │
46+
│ S2B_16PBU_20230506… │ S2B_MSIL2A_2023050… │ T16PBU │ POLYGON ((-88.74518962519173 11.690373971442378, -89.62017907866615 11.8466519… │
47+
│ S2B_16PDU_20230506… │ S2B_MSIL2A_2023050… │ T16PDU │ POLYGON ((-87.91783982214183 11.670141095427311, -87.92096676562824 12.5828090… │
48+
├──────────────────────┴──────────────────────┴─────────┴──────────────────────────────────────────────────────────────────────────────────┤
49+
10 rows 4 columns │
50+
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
51+
```
52+
53+
### POST (WIP)
54+
```sql
55+
D SELECT
56+
http_post(
57+
'https://some.server',
58+
headers => MAP {
59+
'Content-Type': 'application/json',
60+
}::VARCHAR,
61+
params => MAP {
62+
'limit': 1
63+
}::VARCHAR
64+
)
65+
AS data;
66+
```
67+

0 commit comments

Comments
 (0)