Custom Endpoints

As the AerisWeather weather API continues to grow, new endpoints are added and new properties are added to existing ones. In some cases, the weather API may be updated ahead of the Python SDK and the SDK may not yet support a new API endpoint. Or an endpoint may have been updated with new options. For cases like these, the AerisWeather Python library provides a special endpoint type named CUSTOM, and the CustomResponse class. In this section we'll show how to make custom endpoint requests to the weather API.

We do custom requests a little different, in that we need to define the EndpointType and set up an Endpoint object. We then pass that Endpoint object to the aerisweather.request() method and let it generate the request based on the endpoint object's properties.

    EndpointType.custom = "stormreports"

    endpoint = Endpoint(EndpointType.CUSTOM, location=RequestLocation(postal_code="54660"))

As you see above, we can use the endpoint object to handle all of the optional properties as well. Then, as we said above, once we have all of our request properties added to the Endpoint object, we can pass that to the aerisweather.request() method.

    response_list = awx.request(endpt)

We know from what we learned in the The Basics that the request method always returns a list of response objects. We also know that the type of response objects returned depends on the endpoint specified in the request, so that we always get back a response appropriate to the endpoint we're getting data from. In this case then, we will get a list of CustomResponse objects, since we requested data from an unknown (custom) endpoint type.

In the snippet below, we're requesting data from the Aeris API StormReports endpoint. We know this to be a valid endpoint, it's just not fully implemented in the library at the time of this writing.

    # this will be a list of CustomResponse objects
    response_list = aeriswx.request(endpoint)
    response = response_list[0]

    # the response should have storm report data, so let's try to pull the report type
    print("The storm report type is: " +

For more details, you check out the whole custom endpoint example.

Last modified: May 17, 2018