Few questions about Pipes

Hi all,

I have a few questions that’ll hopefully help me wrap my head around pipes.

  1. I installed the weather pipe to experiment with. I want to get weather by zip code rather than city name because city names are not always unique. The API doc for openweathermap states the following…

api.openweathermap.org/data/2.5/forecast/daily?zip={zip code},{country code}&appid={your api key}

Parameters:

zip zip code

In the pipes setting, the slug cannot contain spaces so how would I use the zip code parameter?

  1. Can the parameters be dynamically loaded from a record? For instance, can I get the weather based on an address field for a record?

I updated the weather pipe, if you install it again you’ll see a new API call to get weather by zip code.

  1. You can use any name for the parameters and they most certainly can be loaded from record value.

Just so we’re on the same page:
There are several parts to the URL:

  • Parameter Name
  • Parameter Value

The parameter name is determined by the API you’re using and must be followed strictly. For example, the Weather API requires a parameter of “appid” Passing a different value will return an error. However, the parameter value (in this case appid value) is dynamic.

…appid=123456

appid is the parameter name
123456 is the parameter value.

The parameter value is a value you pass along with your request. Since parameter values are generally dynamic and not hardcoded, you can create custom parameters that will change these values on the fly. This is where the parameters tab comes in. You can create a parameter name which can be any text of your choosing, and the slug can also be anything you choose. The key here is to ensure that the slug you choose matches the slug you put in the URL.

From this example, the Parameter Name of “zip” is not something we can tweak, since this is how the API will utilize this API call.

If the request parameter name (not value) requires a space (for example if it required it to be as follows:
http://api.openweathermap.org/data/2.5/forecast/daily?zip code= the “zip code” part (which contains a space) will get auto URL encoded and it will still work.

1 Like

Thanks for the detailed response!

1 Like