项目作者: nedzadalibegovic

项目描述 :
RESTful API for Federal Hydrometeorological Institute
高级语言: JavaScript
项目地址: git://github.com/nedzadalibegovic/fhmi-api.git
创建时间: 2019-12-22T21:52:23Z
项目社区:https://github.com/nedzadalibegovic/fhmi-api

开源协议:

下载


RESTFul API for Federal Hydrometeorological Institute

REST API that provides weather data for nine cities in Bosnia and Herzegovina (Bihać, Banja Luka, Bugojno, Livno, Mostar, Sarajevo, Trebinje, Tuzla, Zenica). Data is provided from an XML file hosted on the Federal Hydrometeorological Institute website that is updated daily.

Data fetching functionality is provided in the fetch_data.js file.

What routes and methods do you support?

Currently supported routes and methods:

Route Supported Methods
/cities/ GET
/cities/{city_name} GET

Example API call:

  1. GET /cities/bihac
  2. {
  3. "city": "Bihać",
  4. "description": "pretežnooblačno",
  5. "forecasts": [
  6. {
  7. "date": "2020-03-23T00:00:00.000Z",
  8. "low": -3,
  9. "high": 0,
  10. "morning": "pretežno oblačno sa snijegom",
  11. "afternoon": "pretežno oblačno sa snijegom"
  12. },
  13. {
  14. "date": "2020-03-24T00:00:00.000Z",
  15. "low": -3,
  16. "high": 0,
  17. "morning": "pretežno oblačno sa snijegom",
  18. "afternoon": "pretežno oblačno sa snijegom"
  19. },
  20. {
  21. "date": "2020-03-25T00:00:00.000Z",
  22. "low": -2,
  23. "high": 0,
  24. "morning": "pretežno oblačno sa snijegom",
  25. "afternoon": "susnježica"
  26. },
  27. {
  28. "date": "2020-03-26T00:00:00.000Z",
  29. "low": -1,
  30. "high": 1,
  31. "morning": "pretežno oblačno sa snijegom",
  32. "afternoon": "susnježica"
  33. }
  34. ],
  35. "humidity": 0.37,
  36. "pressure": 995.6,
  37. "temperature": 2,
  38. "timestamp": "2020-03-23T11:07:00.000Z",
  39. "windDirection": "N",
  40. "windSpeed": 18
  41. }

Legend

Property Unit Note
low, high, temperature °C low - minimum temperature, high - maximum temperature, temperature - current temperature
humidity % Relative humidity
pressure hPa Atmospheric pressure on the ground level
windSpeed km/h windDirection - wind direction reported in cardinal and intercardinal directions
date, timestamp In ISO 8601 format, timestamp - date when measurments were taken
forecasts Contains 4-day forecast
description, morning, afternoon Textual weather description

How can I host it myself?

You need Node.js, MongoDB and two environment variables (check the .env_sample file), when everything is set up properly, run the data fetching service with:

  1. npm run fetch

For running the API in a dev environment, you can use:

  1. npm run dev

For running in a production environment, you can use:

  1. npm start

Check package.json to see how npm run dev and npm start differ.