forked from dev-magdy/Shreyash-specs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zippopotamus.yaml
193 lines (185 loc) · 5.68 KB
/
zippopotamus.yaml
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
openapi: 3.0.0
info:
version: "1.0"
title: Zippopotam.us API
servers:
- url: https://api.zippopotam.us
components:
parameters:
country:
name: country
in: path
description: ISO 3166-1 Alpha-2 country code e.g "US" for the United States of America
required: true
schema:
type: string
example: US
postalCode:
name: postalcode
in: path
description: Postal code of the place you want to search
required: true
schema:
type: string
example: "84321"
state:
name: state
in: path
description: Two letter state/province abbreviation
required: true
schema:
type: string
example: "UT"
schemas:
NearbyPlaces:
type: object
properties:
near longitude:
type: number
format: float
nearby:
type: array
items:
properties:
distance:
type: number
format: float
place name:
type: string
post code:
type: string
state:
type: string
state abbreviation:
type: string
near latitude:
type: number
format: float
Places:
type: object
properties:
country abbreviation:
type: string
places:
type: array
items:
properties:
place name:
type: string
longitude:
type: string
post code:
type: string
latitude:
type: string
country:
type: string
place name:
type: string
state:
type: string
state abbreviation:
type: string
PostalCode:
type: object
properties:
post code:
type: string
example: "84321"
country:
type: string
example: "United States"
country abbreviation:
type: string
example: "US"
places:
type: array
items:
properties:
place name:
type: string
example: Logan
longitude:
type: string
example: "-111.8226"
state:
type: string
example: Utah
state abbreviation:
type: string
example: UT
latitude:
type: string
example: "41.747"
paths:
"/{country}/{postalcode}":
get:
summary: |
Places by postal code
description: |
Look up places by postal code and country.
> Note: This endpoint will return multiple places where applicable!
In the United States, the place name returned will likely be whatever USPS says is the "Recommended City Name" for that postal code.
This often surprises folks, as they may be used to using the name of the city the address is located in. For example, `84341` returns "Logan"
as its place name, but folks in North Logan also use this same postal code.
You can verify this by using the [USPS tool](https://tools.usps.com/zip-code-lookup.htm?citybyzipcode) to lookup a zip code, and see the "Recommended City Name"
alongside "Other City Names Recognized".
parameters:
- $ref: "#/components/parameters/country"
- $ref: "#/components/parameters/postalCode"
responses:
200:
description: Place located successfully for postalcode in country
content:
application/json:
schema:
$ref: "#/components/schemas/PostalCode"
404:
description: No place found for postalcode in country
"/{country}/{state}/{place}":
get:
summary: |
Postal codes by place
description: |
Look up postal codes by the name of place.
In the United States, this endpoint will not return any results if there aren't any zip codes associated with the place name. This is a common occurrence in locations
where the United States Postal Service services multiple places through the same post office.
parameters:
- $ref: "#/components/parameters/country"
- $ref: "#/components/parameters/state"
- name: place
in: path
description: Name of place (city, town, etc.)
required: true
schema:
type: string
example: Logan
responses:
200:
description: One or more places located successfully
content:
application/json:
schema:
$ref: "#/components/schemas/Places"
404:
description: No places found
"/nearby/{country}/{postalcode}":
get:
summary: |
Places near postal code
description: |
Nearby places by postal code and country
Provided `postalCode` can be found in `country`, this endpoint returns other postal codes and their associated places. Like the other endpoints, the places returned are only going to be places that have an associated postal code.
This endpoint is limited to getting the nearest 11 places.
parameters:
- $ref: "#/components/parameters/country"
- $ref: "#/components/parameters/postalCode"
responses:
200:
description: One or more places located successfully
content:
application/json:
schema:
$ref: "#/components/schemas/NearbyPlaces"
404:
description: No places found