npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

turkey-weather-placeholder

v1.3.0

Published

The 'TurkeyWeather' npm module is a tool for accessing real-time weather data and weather forecast from the Turkish State Meteorological Service (MGM) website.

Downloads

26

Readme

TurkeyWeather

The 'TurkeyWeather' npm module is a tool for accessing real-time weather data and weather forecast from the Turkish State Meteorological Service (MGM) website. With this module, you can effortlessly retrieve a wide range of weather information, including current conditions, daily and hourly forecasts, and the latest weather events, for any province or district in Turkey.

const api = new TurkeyWeather();

api.LatestEvents('Trabzon', 'Ortahisar').then(res => {
    console.log(res.temp);
});

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

The 'TurkeyWeather' module is released under the MIT License.

Documentation

CenterID system

The MGM API uses ids for weather centers around the Turkey. This ids are a 5 digit code that are used for making API calls. For example the code 93432 is for the Ataşehir district of İstanbul.

You can use these codes in the functions to get data. But you don't have to because every function that can work with CenterID system has a built in location name to CenterID converter. For Ataşehir, just passing the parameter ('istanbul', 'ataşehir') to the function should be fine.

Create an API object

const api = new TurkeyWeather();

Get the names of all provinces

api.getProvinceNames()

This function will return all of the province names in Turkey as an array of strings.

[
  'Adana',
  'Adıyaman',
  'Afyonkarahisar', 
  ...
]

Get general information about a center

api.getCenterInfo(96101); //You can pass centerID
api.getCenterInfo("Trabzon","Ortahisar"); //You can pass the name of the center

This function will return the general information about a center like (name, altitude, lat, long, centerID). This function is to be used for getting the centerID of a center using its name. But there is a internal converter for all functions.

{
  provinceID: 60,
  name: 'Ortahisar',
  province: 'Trabzon',
  lat: 40.9985,
  long: 39.7649,
  altitude: 39,
  centerID: 96101,
  hourlyID: 17038
}

Get all the districts of a province

api.getDistricts("Niğde"); //Functions also have internal character conversion.

This Function will return you an array of district objects which contains the district name and its centerID. You cannot use centerID with this function because provinces are too vague to be a weather center.

[
  { name: 'Altunhisar', centerID: 95103 },
  { name: 'Bor', centerID: 95105 },
  { name: 'Merkez', centerID: 95101 },
  { name: 'Ulukışla', centerID: 95102 },
  { name: 'Çamardı', centerID: 95106 },
  { name: 'Çiftlik', centerID: 95104 }
]

Weather Forecasts

There are 3 functions that can give you weather forecasts. 'LatestEvents()', 'DailyForecast()' and 'HourlyForecat()'.

LatestEvents()

api.LatestEvents(96101)
api.LatestEvents("Trabzon", "Ortahisar")

This function will return the latest events in a given weather center. Latest events are like wind speed and direction, current temperature, current humidity and more.

{
  temp: 24.7,
  dataDate: '2023-09-19T11:01:00.000Z',
  eventCode: 'A',
  humidity: 55,
  pressure: 1012.6,
  precipitation: {
    now: 0,
    after10Minutes: 0,
    after1Hour: 0,
    after6Hour: 0,
    after12Hour: 0,
    after24Hour: 0
  },
  wind: { speed: 7.2, direction: 321 }
}

DailyForecast()

api.DailyForecast(96101)
api.DailyForecast("Trabzon", "Ortahisar")

This function will return 5 day of weather forecast from today of a given weather center in an array of daily forecast objects.

[
  {
    date: '2023-09-20T00:00:00.000Z',
    event: 'PB',
    temp: { lowest: 20, highest: 25 },
    humidity: { lowest: 65, highest: 92 },
    wind: { speed: 14, direction: 15 }
  },
  {
    date: '2023-09-21T00:00:00.000Z',
    event: 'GSY',
    temp: { lowest: 21, highest: 25 },
    humidity: { lowest: 79, highest: 87 },
    wind: { speed: 10, direction: 19 }
  },
  ...
]

HourlyForecast()

api.HourlyForecast(96101)
api.HourlyForecast("Trabzon", "Ortahisar")

This function will return hourly weather forecasts of a given weather center in an array of hourly forecast objects. The forecasts are in 3 hour intervals.

[
  {
    date: '2023-09-19T12:00:00.000Z',
    temp: 24,
    apparentTemp: 24,
    event: 'PB',
    humidity: 69,
    wind: { speed: 8, maxSpeed: 27, direction: 40 }
  },
  {
    date: '2023-09-19T15:00:00.000Z',
    temp: 23,
    apparentTemp: 23,
    event: 'PB',
    humidity: 68,
    wind: { speed: 2, maxSpeed: 16, direction: 51 }
  },
  ...
]