Monday, March 1, 2021
  • Setup menu at Appearance » Menus and assign menu to Top Bar Navigation
Advertisement
  • AI Development
    • Artificial Intelligence
    • Machine Learning
    • Neural Networks
    • Learn to Code
  • Data
    • Blockchain
    • Big Data
    • Data Science
  • IT Security
    • Internet Privacy
    • Internet Security
  • Marketing
    • Digital Marketing
    • Marketing Technology
  • Technology Companies
  • Crypto News
No Result
View All Result
NikolaNews
  • AI Development
    • Artificial Intelligence
    • Machine Learning
    • Neural Networks
    • Learn to Code
  • Data
    • Blockchain
    • Big Data
    • Data Science
  • IT Security
    • Internet Privacy
    • Internet Security
  • Marketing
    • Digital Marketing
    • Marketing Technology
  • Technology Companies
  • Crypto News
No Result
View All Result
NikolaNews
No Result
View All Result
Home Learn to Code

weatherstack: an Amazing Weather API

September 18, 2019
in Learn to Code
weatherstack: an Amazing Weather API
589
SHARES
3.3k
VIEWS
Share on FacebookShare on Twitter

One of my first tasks each day is checking the weather; it’s a necessity for knowing what my children and I should wear, if I’m going to need to water the lawn or need to shovel snow, and if I can take meetings out on my patio. It’s also been one of my worst web experiences because Weather.com is slow, difficult to navigate, and plastered with dozens of trackers and advertisements. Luckily I recently discovered an API so I can create my own weather dashboard with the WeatherStack API.

You might also like

How to Install a NPM Module from GitHub Branch

How to Push to a Git Remote Branch of a Different Name

Fix “no such file or directory, scandir”

Quick Hits

  • Free to start!
  • Global weather information with one easy to use API
  • Get both realtime, historical, and forecast weather data
  • Sample code for implementing the API in Ruby, Node.js, Go, Python, PHP, and even jQuery
  • Trusted by 75,000 companies including Microsoft and Warner Brothers
  • From the creators of currencylayer, ipstack, mailboxlayer, and more rock solid APIs

Start by signing up for free — you’ll immediately be provided an API token to use, as well as get detailed API instructions for usage.

Basic Usage

To get the realtime weather data for a given location, make a simple API call with the language and method of your choice:

// Getting weather by postal code in Fahrenheit
http://api.weatherstack.com/current
    ?access_key=YOUR_API_KEY
    &query=53711
    &units=f

You will receive a wealth of information in the response:

{
   "request":{
      "type":"Zipcode",
      "query":"53711",
      "language":"en",
      "unit":"f"
   },
   "location":{
      "name":"Madison",
      "country":"USA",
      "region":"Wisconsin",
      "lat":"43.031",
      "lon":"-89.444",
      "timezone_id":"America/Chicago",
      "localtime":"2019-09-14 14:25",
      "localtime_epoch":1568471100,
      "utc_offset":"-5.0"
   },
   "current":{
      "observation_time":"07:25 PM",
      "temperature":72,
      "weather_code":116,
      "weather_icons":[
         "https://assets.weatherstack.com/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png"
      ],
      "weather_descriptions":[
         "Partly cloudy"
      ],
      "wind_speed":8,
      "wind_degree":210,
      "wind_dir":"SSW",
      "pressure":1021,
      "precip":0,
      "humidity":57,
      "cloudcover":75,
      "feelslike":77,
      "uv_index":6,
      "visibility":10
   }
}

You can specify location by city name, latitude/longitude, postal code, IP address, or even Geolocation via the fetch:ip option.

You can also get weather information for multiple locations with on request by separating separate locations with a ;; you’ll receive an array of objects representing each location.

Units and Languages

weatherstack also allows developers to specify language and units. Imagine being French and arriving in the United States. Ideally you want the weather information in your local language (French) in and units you understand (Celcius, kilometers, etc.). Add the following parameters to your request:

// Getting weather in French and metric system
http://api.weatherstack.com/current
    ?access_key=YOUR_API_KEY
    &query=New York
    &units=m
    &language=fr

The response payload will provide temperature in Celcius, wind in kilometers, precipitation in millimeters, and snow in centimeters. Letting weatherstack do the localization for you (and your users) is a huge task you don’t need to worry about!

Historical Weather

If you would like historical weather information for a given location and date, hit the /historical endpoint:

// Weather from last July 5th in hour increments
http://api.weatherstack.com/current
    ?access_key=YOUR_API_KEY
    &query=Madison
    &historical_date=2018-07-05
    &units=f
    &hourly=1

The historical endpoint allows a single past date or multiple dates separated by ; via the historical_date method.

The historical endpoint also offers two new options: hourly and interval. hourly values are 1 (on) or 0 (off) values which specify if you’d like hourly weather information. The interval represents the hour increments you’d like values for (1, 3, 6, 12, and 24).

Forecast

A very typical use case is wanting to know a weeks worth of weather outlook. For that you can hit the /forecast API endpoint. The important parameter when using the forecast endpoint is forecast_days, with the maximum value being 14.

// Weather for the next 14 days
http://api.weatherstack.com/current
    ?access_key=YOUR_API_KEY
    &query=Madison
    &forecast_days=14
    &units=f
    &hourly=1

All of the previously mentioned parameters can be used for the forecast API!

weatherstack is just another amazing API from apilayer. You can always count on them to keep the API simple and reliable, and coupled with their numerous other APIs, you can create an insanely personalized experience for your users. If you want to provide an awesome weather experience for your users, try weatherstack!

Credit: DavidWalsh By: David Walsh

Previous Post

Huawei urges Australia to embrace better Chinese products

Next Post

2020 Salaries for Marketing, Advertising, and PR Positions

Related Posts

How to Change the WordPress Admin Login Logo
Learn to Code

How to Install a NPM Module from GitHub Branch

February 12, 2021
How to Change the WordPress Admin Login Logo
Learn to Code

How to Push to a Git Remote Branch of a Different Name

February 9, 2021
How to Change the WordPress Admin Login Logo
Learn to Code

Fix “no such file or directory, scandir”

February 8, 2021
How to Change the WordPress Admin Login Logo
Learn to Code

Confessions of a Web Developer XVIII

February 3, 2021
How to Change the WordPress Admin Login Logo
Learn to Code

JavaScript Wake Lock API

January 25, 2021
Next Post
2020 Salaries for Marketing, Advertising, and PR Positions

2020 Salaries for Marketing, Advertising, and PR Positions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended

Plasticity in Deep Learning: Dynamic Adaptations for AI Self-Driving Cars

Plasticity in Deep Learning: Dynamic Adaptations for AI Self-Driving Cars

January 6, 2019
Microsoft, Google Use Artificial Intelligence to Fight Hackers

Microsoft, Google Use Artificial Intelligence to Fight Hackers

January 6, 2019

Categories

  • Artificial Intelligence
  • Big Data
  • Blockchain
  • Crypto News
  • Data Science
  • Digital Marketing
  • Internet Privacy
  • Internet Security
  • Learn to Code
  • Machine Learning
  • Marketing Technology
  • Neural Networks
  • Technology Companies

Don't miss it

Machine Learning as a Service (MLaaS) Market Analysis Technological Innovation by Leading Industry Experts and Forecast to 2028 – The Daily Chronicle
Machine Learning

Machine Learning as a Service (MLaaS) Market Global Sales, Revenue, Price and Gross Margin Forecast To 2028 – The Bisouv Network

March 1, 2021
AI And Automation In HR: The Changing Scenario Of The Business
Data Science

AI And Automation In HR: The Changing Scenario Of The Business

February 28, 2021
Machine learning could aid mental health diagnoses: Study
Machine Learning

Machine learning could aid mental health diagnoses: Study

February 28, 2021
Python vs R! Which one should you choose for data Science
Data Science

Python vs R! Which one should you choose for data Science

February 28, 2021
Can Java be used for machine learning and data science?
Machine Learning

Can Java be used for machine learning and data science?

February 28, 2021
These four new hacking groups are targeting critical infrastructure, warns security company
Internet Security

These four new hacking groups are targeting critical infrastructure, warns security company

February 28, 2021
NikolaNews

NikolaNews.com is an online News Portal which aims to share news about blockchain, AI, Big Data, and Data Privacy and more!

What’s New Here?

  • Machine Learning as a Service (MLaaS) Market Global Sales, Revenue, Price and Gross Margin Forecast To 2028 – The Bisouv Network March 1, 2021
  • AI And Automation In HR: The Changing Scenario Of The Business February 28, 2021
  • Machine learning could aid mental health diagnoses: Study February 28, 2021
  • Python vs R! Which one should you choose for data Science February 28, 2021

Subscribe to get more!

© 2019 NikolaNews.com - Global Tech Updates

No Result
View All Result
  • AI Development
    • Artificial Intelligence
    • Machine Learning
    • Neural Networks
    • Learn to Code
  • Data
    • Blockchain
    • Big Data
    • Data Science
  • IT Security
    • Internet Privacy
    • Internet Security
  • Marketing
    • Digital Marketing
    • Marketing Technology
  • Technology Companies
  • Crypto News

© 2019 NikolaNews.com - Global Tech Updates