-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurl.sh
More file actions
71 lines (63 loc) · 3.78 KB
/
curl.sh
File metadata and controls
71 lines (63 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
# Unlocoder API examples using curl
# Get your free API key at: https://rapidapi.com/contactliamnoonan/api/unlocoder
API_KEY="YOUR_RAPIDAPI_KEY"
HOST="unlocoder.p.rapidapi.com"
BASE="https://$HOST"
# ──────────────────────────────────────────────
# 1. Convert coordinates (Decimal Degrees)
# ──────────────────────────────────────────────
echo "=== Convert DD ==="
curl -s -X POST "$BASE/api/convert" \
-H "Content-Type: application/json" \
-H "x-rapidapi-key: $API_KEY" \
-H "x-rapidapi-host: $HOST" \
-d '{"input": "51.5074, -0.1278"}' | jq .
# ──────────────────────────────────────────────
# 2. Convert coordinates (DMS format)
# ──────────────────────────────────────────────
echo "=== Convert DMS ==="
curl -s -X POST "$BASE/api/convert" \
-H "Content-Type: application/json" \
-H "x-rapidapi-key: $API_KEY" \
-H "x-rapidapi-host: $HOST" \
-d '{"input": "40°42'\''46\"N 74°0'\''22\"W"}' | jq .
# ──────────────────────────────────────────────
# 3. Convert with custom precision (10 dp)
# ──────────────────────────────────────────────
echo "=== Convert with precision ==="
curl -s -X POST "$BASE/api/convert" \
-H "Content-Type: application/json" \
-H "x-rapidapi-key: $API_KEY" \
-H "x-rapidapi-host: $HOST" \
-d '{"input": "51.5074, -0.1278", "precision": 10}' | jq .
# ──────────────────────────────────────────────
# 4. Resolve a UN/LOCODE via convert endpoint
# ──────────────────────────────────────────────
echo "=== Resolve UN/LOCODE ==="
curl -s -X POST "$BASE/api/convert" \
-H "Content-Type: application/json" \
-H "x-rapidapi-key: $API_KEY" \
-H "x-rapidapi-host: $HOST" \
-d '{"input": "GBLON"}' | jq .
# ──────────────────────────────────────────────
# 5. Lookup UN/LOCODE directly
# ──────────────────────────────────────────────
echo "=== Lookup GBLON ==="
curl -s "$BASE/unlocodes/GBLON" \
-H "x-rapidapi-key: $API_KEY" \
-H "x-rapidapi-host: $HOST" | jq .
# ──────────────────────────────────────────────
# 6. Lookup with reference time (historical offset)
# ──────────────────────────────────────────────
echo "=== Lookup with reference time ==="
curl -s "$BASE/unlocodes/USNYC?referenceTime=2025-07-15T12:00:00Z" \
-H "x-rapidapi-key: $API_KEY" \
-H "x-rapidapi-host: $HOST" | jq .
# ──────────────────────────────────────────────
# 7. Find nearby UN/LOCODEs
# ──────────────────────────────────────────────
echo "=== Nearby UN/LOCODEs ==="
curl -s "$BASE/unlocodes/nearby?latitude=40.7128&longitude=-74.0060" \
-H "x-rapidapi-key: $API_KEY" \
-H "x-rapidapi-host: $HOST" | jq .