Get the weather

This is for:

Developer

Qubit’s Weather API allows the lookup of the current weather or a forecast–from between one and fourteen days–for the user’s current location.

To deliver weather and forecasts, we call the Weather API, a third-party solution from OpenWeather.

Tip
Leading practice

We cache the weather conditions for the given location for 5 minutes.

As with all geolocation services, this uses an Internet Protocol address (IP) as a unique identifier to lookup a computer or computer network location.

Warning

We would therefore like to point out that using an IP to retrieve current weather and forecasts, when serving experiences or segmenting for example, is not 100% accurate.

Prerequisites

Unique values

Before using the Weather API, you will require the following unique values:

Name Description

<tracking_id>

CEH tracking ID for the property the request is made from. This will be provided by your Customer Success manager at Coveo.

<visitor_id>

Unique site visitor ID, generated by the Smartserve script on the page and is set in the cookies qb_permanent and qbTracker.

Retrieving the current weather

To get the current weather in the location of the user, make a GET request to the following URL:

https://orca.qubitproducts.com/www/status/<temp-unit>?cid=<visitor_id>&id=<tracking_id>

Where:

  • temp-unit is either c for Celsius or f for Fahrenheit

Let’s have a look at a few examples.

Temperature in Celsius

https://orca.qubitproducts.com/www/status/c?cid=<visitor_id>&id=<tracking_id>

Example response

{
  weather: {
    coord: {
      lon: -0.1,
      lat: 51.51
    },
    sys: {
      type: 1,
      id: 5093,
      message: 0.0041,
      country: 'GB',
      sunrise: 1441170902,
      sunset: 1441219499
    },
    weather: [{
      id: 501,
      main: 'Rain',
      description: 'moderate rain',
      icon: '10n'
    }],
    base: 'cmc stations',
    main: {
      temp: 12.31,
      pressure: 1017,
      humidity: 82,
      temp_min: 11,
      temp_max: 14
    },
    wind: {
      speed: 2.6,
      deg: 310
    },
    rain: {
      1h: 2.29
    },
    clouds: {
      all: 56
    },
    dt: 1441232467,
    id: 6545174,
    name: 'Kennington',
    cod: 200
  },
  geo: {
    ip: '86.13.100.143',
    country: 'GB',
    country_string: 'united kingdom',
    region: '25447',
    region_string: 'london',
    metro_area: '826044',
    metro_area_string: 'itv london',
    city: '4782',
    city_string: 'london',
    latitude: '51.5149',
    longitude: '-0.095189'
  }
}

Temperature in Fahrenheit

https://orca.qubitproducts.com/www/status/f?cid=<visitor_id>&id=<tracking_id>

Example response

{
  weather: {
    coord: {
      lon: -0.1,
      lat: 51.51
    },
    sys: {
      type: 1,
      id: 5093,
      message: 0.0062,
      country: 'GB',
      sunrise: 1441170902,
      sunset: 1441219499
    },
    weather: [{
      id: 501,
      main: 'Rain',
      description: 'moderate rain',
      icon: '10n'
    }],
    base: 'cmc stations',
    main: {
      temp: 54.14,
      pressure: 1017,
      humidity: 82,
      temp_min: 51.8,
      temp_max: 57.2
    },
    wind: {
      speed: 5.62,
      deg: 310
    },
    rain: {
      1h: 1.27
    },
    clouds: {
      all: 56
    },
    dt: 1441233067,
    id: 2637221,
    name: 'Spitalfields',
    cod: 200
  },
  geo: {
    ip: '86.13.100.143',
    country: 'GB',
    country_string: 'united kingdom',
    region: '25447',
    region_string: 'london',
    metro_area: '826044',
    metro_area_string: 'itv london',
    city: '4782',
    city_string: 'london',
    latitude: '51.5149',
    longitude: '-0.095189'
  }
}

Retrieving the forecast

To get the weather forecast, for between one and fourteen days, in the location of the user, make a GET request to the following URL:

Temperatures in celsius

https://orca.qubitproducts.com/www/forecast/<number_of_days>/<temp-unit>?cid=<visitor_id>&id=<tracking_id>

Where
  • temp-unit is either c for Celsius or f for Fahrenheit

  • number_of_days is the number of days you want to retrieve the forecast for.

Note

If the number of days isn’t specified, a default of seven days is used.

Example response

{
  weather: {
    cod: '200',
    message: 0.001,
    city: {
      id: 2643744,
      name: 'City of London',
      coord: {
        lon: -0.08901,
        lat: 51.51334
      },
      country: 'GB',
      population: 0
    },
    cnt: 10,
    list: [{
      dt: 1441191600,
      temp: {
        day: 11.82,
        min: 10.86,
        max: 11.82,
        night: 10.86,
        eve: 11.82,
        morn: 11.82
      },
      pressure: 1023.17,
      humidity: 70,
      weather: [{
        id: 804,
        main: 'Clouds',
        description: 'overcast clouds',
        icon: '04n'
      }],
      speed: 3.72,
      deg: 299,
      clouds: 92
    }, {
      dt: 1441278000,
      temp: {
        day: 15.03,
        min: 9.76,
        max: 15.83,
        night: 12.1,
        eve: 14.03,
        morn: 9.76
      },
      pressure: 1020.82,
      humidity: 74,
      weather: [{
        id: 802,
        main: 'Clouds',
        description: 'scattered clouds',
        icon: '03d'
      }],
      speed: 5.51,
      deg: 293,
      clouds: 48
    }]
  },
  geo: {
    ip: '86.13.100.143',
    country: 'GB',
    country_string: 'united kingdom',
    region: '25447',
    region_string: 'london',
    metro_area: '826044',
    metro_area_string: 'itv london',
    city: '4782',
    city_string: 'london',
    latitude: '51.5149',
    longitude: '-0.095189'
  }
}

Weather codes

Within each response, we return a code cod, indicating the current or forecasted weather for the user’s location. In the following example, the returned code is 200:

{
  weather: {
    cod: '200',
    message: 0.001,
    city: {
      id: 2643744,
      name: 'City of London',
      coord: {
        lon: -0.08901,
        lat: 51.51334
      },
      country: 'GB',
      population: 0
    }
  }
}

Refer to the following tables for a description of each code.

Thunderstorm

Code Description

200

Thunderstorm with light rain

201

Thunderstorm with rain

202

Thunderstorm with heavy rain

210

Light thunderstorm

211

Thunderstorm

212

Heavy thunderstorm

221

Ragged thunderstorm

230

Thunderstorm with light drizzle

231

Thunderstorm with drizzle

232

Thunderstorm with heavy drizzle

Drizzle

Code Description

301

Drizzle

302

Heavy intensity drizzle

310

Light intensity drizzle rain

311

Drizzle rain

312

Heavy intensity drizzle rain

313

Shower rain and drizzle

314

Heavy shower rain and drizzle

321

Shower drizzle

Rain

Code Description

500

Light rain

501

Moderate rain

502

Heavy intensity rain

503

Very heavy rain

504

Extreme rain

511

Freezing rain

520

Light intensity shower rain

521

Shower rain

522

Heavy intensity shower rain

531

Ragged shower rain

Snow

Code Description

600

Light snow

601

Snow

602

Heavy snow

611

Sleet

612

Shower sleet

615

Light rain and snow

616

Rain and snow

620

Light shower snow

621

Shower snow

622

Heavy shower snow

Atmosphere

Code Description

701

Mist

711

Smoke

721

Haze

731

Sand/dust whirls

741

Fog

751

Sand

761

Dust

762

Volcanic ash

771

Squalls

781

Tornado

Clear

Code Description

800

Clear sky

Clouds

Code Description

801

Few clouds

802

Scattered clouds

803

Broken clouds

804

Overcast clouds