The places/postal codes endpoint provides information on US ZIP codes and Canadian Postal Codes. US 5-digit ZIP codes and Canadian 6-character postal codes are supported.
The following actions are supported with the places/postalcodes endpoint:
:id | Requesting data by using the :id action is used for returning data for a particular item that has an ID associated with it. This is the primary method for requesting general weather information for a single location (observations, forecasts, advisories, etc.) as the location's name or a zip code serves as the id. Other endpoints may expect a certain value for the ID, such as storm cells whose ID value is a combination of the radar site identifier and unique identifier assigned to every storm cell. Refer to an endpoint's detailed documentation for specific information regarding how to use the :id action. |
closest | The closest action will query the API for data that is closest to the requested place and return the results, if any, in order from closest to farthest. If no limit is provided in the request, then only the closest single result will be returned. If your request does not return results, you may try setting or increasing the radius being used. |
within | The within action allows for returning data within a variety of different geometrical regions. Currently supported geometries include a circle (requires a center point and radius), rectangle (requires two coordinate points defining the top-left and bottom-right corners) and polygon (requires at least three coordinate points). Unlike the closest action, the results will not be returned in any particular order based on distance. |
search | The search action is used as a more general query method and expects the query to be defined with the custom query for the request. Unlike the closest action, results will not be returned in any particular order. |
The following parameters are optional unless otherwise noted:
p | p=:place |
Defines the location to query data for. Refer to the list of supported place value formats. |
limit | limit=:total |
The total number of results to return as an integer. Each endpoint may have a set maximum for this value depending on usage. The default limit is 1 if not specified. The maximum limit for this endpoint is 250. |
radius | radius=:distance:unit |
When requesting the closest results within a circle, the radius determines how far from the specified location to search. A valid unit value must be included in your radius value, e.g., "5mi", "10km", "25miles". If no unit is provided, your value is assumed to be in meters by default. Most endpoints utilize a default radius of 50 miles, though some endpoints, such as lightning, may have tighter restrictions specified. |
minradius | minradius=:distance:unit |
When requesting the closest results within a circle, the minradius determines how far from the specified location to search to begin searching results. A valid unit value must be included in your minimum radius value, e.g., "5mi", "10km", or "25miles". If no unit is provided, your value is assumed to be in meters by default. When combined with the radius parameter, donut style queries can be made for point data, such as lightning. |
filter | filter=:string |
Predefined filters for limiting the results. The filter value can be a single, comma-delimited or a semicolon delimited string of filter names. |
query | query=:string |
Used to filter results based on certain fields in the data set. See Advanced Queries for more details. |
sort | sort=:string |
Used to sort results based on certain fields in the data set. See Sorting for more details. |
skip | skip=:number |
Used to skip over a specific number of results in the data set. |
fields | fields=:string |
Provides a comma separated list of values for the API to return. This parameter is often used to limit the amount of data returned. See Reducing Output. |
format | format=:string |
Defines the API output format. The available options include:format=json - Standard JSON output. This is the default.format=geojson - API will output GeoJSON.If obtaining GeoJSON and using the fields parameter, be sure to include loc to ensure geographical references are available in the response.
|
The following filters can be passed to the filter parameter to reduce the results that are returned:
us | Returns US zip code information. (Default) |
ca, canada | Returns Canadian postal code information. |
standard | Returns only standard location types. |
Use the following supported property keys when creating custom queries for your requests:
id | Query by the postal code. |
zip | Query by the zip code (alias for id). |
postalcode | Query by the postal code (alias for id). |
name | Query by the name of the postal code. |
city | Query by the city name for the postal code. |
state | Query by the 2-letter state abbreviation for the postal code. |
country | Query by the 2-letter country abbreviation for the postal code. |
type | Query by the postal code type. |
You can use the following fields to sort data. Review the sorting docs page for more information on the sort functionality.
id | Sort based on the postal code. |
zip | Sort based on the zip code (alias for id). |
postalcode | Sort based on the postal code (alias for id). |
name | Sort based on the name of the postal code. |
city | Sort based on the postal code's city name. |
type | Sort based on the postal code type. |
The /[:endpoint]/[:action]?
portion within the query template below can be exchanged with any of the examples. Also, please note you will need to input your client credentials in the [ID]
and [SECRET]
fields which can be found under the Apps section of the members area.
https://api.aerisapi.com/[:endpoint]/[:action]?client_id=[ID]&client_secret=[SECRET]
Look up US zip code 55403. (Minneapolis, MN)/places/postalcodes/55403?
Look up Canadian postal code./places/postalcodes/M4B 1B3?
Look up Canadian postal code, note the space after the first three characters is optional./places/postalcodes/M4B1B3?
Return the location closest US zip code (based on zip code centroid) to the coordinate 42.25N, 95.25W./places/postalcodes/closest?p=42.95,-95.25&
Find the closest Canadian postal code to the coordinate 43.65, -76.92./places/postalcodes/closest?p=43.65,-76.92&filter=canada&
The following is an example of what each object in the response will consist of. Depending on your requested action, the response may contain multiple instances of this object within an array.
{
"success": true,
"error": null,
"response": {
"id": "L5P 1B2",
"loc": {
"lat": 43.67865,
"long": -79.6286
},
"place": {
"name": "Mississauga",
"state": "ON",
"stateFull": "Ontario",
"country": "CA",
"countryFull": "Canada",
"region": "",
"regionFull": "",
"continent": "na",
"continentFull": "North America"
},
"profile": {
"pop": null,
"tz": "America\/Toronto",
"tzname": "EDT",
"tzoffset": -14400,
"isDST": true,
"wxzone": ["CLC-046620", "CLC-046600"],
"firezone": null,
"fips": null,
"countyid": null,
"active": true
}
}
}
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": "L5P 1B2",
"geometry": {
"type": "Point",
"coordinates": [-79.6286, 43.67865]
},
"properties": {
"id": "L5P 1B2",
"loc": {
"lat": 43.67865,
"long": -79.6286
},
"place": {
"name": "Mississauga",
"state": "ON",
"stateFull": "Ontario",
"country": "CA",
"countryFull": "Canada",
"region": "",
"regionFull": "",
"continent": "na",
"continentFull": "North America"
},
"profile": {
"pop": null,
"tz": "America\/Toronto",
"tzname": "EDT",
"tzoffset": -14400,
"isDST": true,
"wxzone": ["CLC-046620", "CLC-046600"],
"firezone": null,
"fips": null,
"countyid": null,
"active": true
}
}
}]
}
The following properties will be provided in every response object:
Last modified: October 05, 2022