Home > Helparticles > PRO JCI Plugin and the API of openweathermap.org

PRO JCI Plugin and the API of openweathermap.org

The API of openweathermap.org gives Feeds like https://samples.openweathermap.org/ and inside that JSON like https://samples.openweathermap.org/data/2.5/weather?q=London&appid=…

This can be used by the PRO JSON Content Importer Plugin for searching the weather:

For that you need a Shortcode and a JCI-Template.

1. The Shortcode:

[jsoncontentimporterpro id=ID_OF_TEMPLATE httpstatuscodemustbe200=no]

is all you need as Shortcode on a WordPress-Page, – Post or CPT.
“httpstatuscodemustbe200=no” is required, as the API answers with an http-Error when a place can’t be found.

2. The JCI-Template:

There fill these fields: URL:
http://api.openweathermap.org/data/2.5/weather?q={%if urlparam.cit %}{{urlparam.cit}}{% else %}München{% endif %}&lang=de&units=metric&APPID=YOUR_API_KEY
{% set sea = "" %}
{% if urlparam.cit == "" %}
{% set sea = "London" %}
{% else %}
{% set sea = urlparam.cit %}
{% endif %}

{% if cod!="200" %} Place not found {% else %}


Windspeed: {{wind.speed}} m/s, Winddirection: {{wind.deg}}
Temperature: {{main.temp}} ℃, feeels like: {{main.feels_like}} ℃
Pressure: {{main.pressure}} hPa, Humidity: {{main.humidity}}% {% endif %}