Using ITE to convert zip codes to custom URLs

One of my clients wants to include a customizable weather section in their app but can’t afford our usual workflow, an Accuweather integration to pull in custom weather and graphics. Users will enter their zip code into their profile and, based on the zip entered, a custom link to an Accuweather forecast page URL will be displayed.

A hard-coded ITE column inside the Users table would be the most straight-forward solution, but this app covers an entire state with 317 zip codes and I’m not sure if the ITE column has a cases limit?

I’m sure there’s a more dynamic solution — like maybe setting up a separate table with zip code to corresponding Accuweather URL, setting up a relation from this table to the Users table, then looking up the custom weather URLs — but I’m having a hard time wrapping my head around how to do this?

Any insight or suggestions would be greatly appreciated!

How “custom” are you having it for Accuweather?

Is there an opportunity to search for a location programatically based on the ZIP entered, and construct the final Accuweather URL with that location ID?

Hey, @ThinhDinh. I appreciate the input. Below is an example of an Accuweather URL:

https://www.accuweather.com/en/us/minneapolis/55415/weather-forecast/348794

I already have a ticket into Accuweather to better understand how the last 6 digits are generated or what they mean since the URL already lists the language, country, city, and zip. So, even if we use a Template column to construct a custom link, the link is invalid without the 6-digit code at the end.

My other thought was using a single JavaScript column that would display a hard-coded Accuweather URL based on the zip code entered, but I’m not familiar enough myself with JS to write my own but could easily append a sample script that only covered say 3 pairs.

However, I don’t want to create a drag on the app with an ITE column with 317 cases or JS that has 317 pairs in it so not sure where to go from here?

Like I mentioned earlier, the cleanest way is hard-coding 317 pairs in an ITE column but I don’t want to get 100 pairs into the column and then get an error msg stating that ITE columns are limited to 100 cases. :roll_eyes:

Here’s what I got from Perplexity.

Programatically way to get an accuweather URL for a ZIP code, using cURL with only the ZIP code as an input.

You are correct; a standard AccuWeather weather forecast URL includes a unique Location Key, not just the ZIP code. For example, in the URL https://www.accuweather.com/en/us/minneapolis/55415/weather-forecast/348794, the number 348794 is the Location Key for Minneapolis[1][2].

To programmatically obtain this URL using only a ZIP code, you must use the AccuWeather API in a two-step process. First, you find the Location Key associated with the ZIP code, and second, you use that key to retrieve weather data which includes a “Deep Link” to the forecast page[1:1][3]. This process requires an API key, which you can get by registering on the AccuWeather developer portal[2:1].

Here is a step-by-step guide to achieving this using cURL[4].

Step 1: Find the Location Key for a ZIP Code

Use the AccuWeather Locations API to search for a location by its postal code. This will return a JSON object containing the unique Location Key[5][2:2].

API Endpoint:

http://dataservice.accuweather.com/locations/v1/search

cURL Command:
Replace YOUR_API_KEY with your key and ZIP_CODE with the desired ZIP code.

curl "http://dataservice.accuweather.com/locations/v1/search?apikey=YOUR_API_KEY&q=ZIP_CODE"

Example (for ZIP code 55415):

curl "http://dataservice.accuweather.com/locations/v1/search?apikey=YOUR_API_KEY&q=55415"

Example Response:
The API will return a JSON array. You need to parse this response to extract the value of the Key field. For the ZIP code 55415, the key is 348794[3:1].

[
  {
    "Version": 1,
    "Key": "348794",
    "Type": "City",
    "Rank": 31,
    "LocalizedName": "Minneapolis",
    "EnglishName": "Minneapolis",
    "PrimaryPostalCode": "55415",
    "Region": {
      "ID": "NAM",
      "LocalizedName": "North America",
      "EnglishName": "North America"
    },
    "Country": {
      "ID": "US",
      "LocalizedName": "United States",
      "EnglishName": "United States"
    },
    "AdministrativeArea": {
      "ID": "MN",
      "LocalizedName": "Minnesota",
      "EnglishName": "Minnesota",
      "Level": 1,
      "LocalizedType": "State",
      "EnglishType": "State",
      "CountryID": "US"
    },
    // ... more data
  }
]

Step 2: Retrieve the Weather Forecast URL (Deep Link)

With the Location Key obtained in the first step, you can now query a forecast endpoint. The response from this endpoint contains the direct URL to the full forecast on the AccuWeather website[1:2][2:3].

API Endpoint:

http://dataservice.accuweather.com/forecasts/v1/daily/1day/{LOCATION_KEY}

cURL Command:
Replace YOUR_API_KEY with your key and LOCATION_KEY with the key from Step 1 (e.g., 348794).

curl "http://dataservice.accuweather.com/forecasts/v1/daily/1day/LOCATION_KEY?apikey=YOUR_API_KEY"

Example (for Location Key 348794):

curl "http://dataservice.accuweather.com/forecasts/v1/daily/1day/348794?apikey=YOUR_API_KEY"

Example Response:
The JSON response will contain a Headline object and a DailyForecasts array. Both sections include a Link field, which is the URL you need[6].

{
  "Headline": {
    "EffectiveDate": "2022-01-14T07:00:00-05:00",
    "Text": "Turning much colder today and tomorrow",
    "Category": "cooler",
    "Link": "http://www.accuweather.com/en/us/minneapolis/55415/daily-weather-forecast/348794?lang=en-us"
  },
  "DailyForecasts": [
    {
      "Date": "2022-01-13T07:00:00-05:00",
      "Temperature": { ... },
      "Day": { ... },
      "Night": { ... },
      "Sources": [ "AccuWeather" ],
      "MobileLink": "http://www.accuweather.com/en/us/minneapolis/55415/daily-weather-forecast/348794?lang=en-us",
      "Link": "http://www.accuweather.com/en/us/minneapolis/55415/daily-weather-forecast/348794?lang=en-us"
    }
  ]
}

The value of the Link or MobileLink field is the programmatically retrieved AccuWeather URL for the initial ZIP code.


  1. AccuWeather Enterprise API - Deep Links ↩︎ ↩︎ ↩︎

  2. https://apidev.accuweather.com/developers/Media/Default/PDF/QuickStart-en-us.pdf ↩︎ ↩︎ ↩︎ ↩︎

  3. https://stackoverflow.com/questions/71209049/react-accuweather-location ↩︎ ↩︎

  4. tools.ai_integration ↩︎

  5. AccuWeather Enterprise API - Locations ↩︎

  6. https://stackoverflow.com/questions/70707372/get-data-from-accuweather-api-url ↩︎

2 Likes

Thx, ThinhDinh. Great idea to use Perplexity! Not opposed to using an API to get the key since we’re already using Accuweather’s API for the other clients who want real-time forecast and graphics. But, as I understand what Glide considers to be updates, grabbing the Location Keys dynamically introduces an external data source — Google Sheets to connect to Accuweather’s API — and now the app will consume an update every time a user enters or edits their zip code. :\ This client’s operational budget for the app isn’t substantial.

Unless someone is able to chime in and let me know if the ITE column has a case/pair limit, I’ll put in a ticket to w/Glide to see if there is a limit.

As alway, I appreciate your time and expertise @ThinhDinh! :+1:

Wouldn’t this be just an API call? It’s correct you would consume updates with this approach, and you also have to be on a tier high enough to do API calls though.

If updates is a concern, I would:

  • Create a table that contains all ZIP codes.
  • Create a workflow that loops through each code and either do an API call or trigger a Make/Zapier webhook, then write the full Accuweather URL back.
  • Do a relation in Glide to retrieve the URL based on the ZIP code.

That way, you’ll consume the updates only once and the URLs are unlikely to change.

1 Like

Love it, great idea to minimize the updates since client isn’t on a high enough tier for API calls. Plus, this eliminates all hard-coding or bloated ITE column. Thx again!

1 Like