{"id":16275147,"url":"https://github.com/vijinho/stormyglass","last_synced_at":"2025-10-29T15:31:17.350Z","repository":{"id":71221189,"uuid":"152518068","full_name":"vijinho/stormyglass","owner":"vijinho","description":"PHP CLI script and webservice to fetch, save and output data from the stormglass Global Marine Weather Forecast API weather API https://docs.stormglass.io/?shell#point-request and cache/save results, outputting in JSON format","archived":false,"fork":false,"pushed_at":"2020-08-19T14:24:04.000Z","size":4967,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-22T06:20:28.689Z","etag":null,"topics":["json-api","marine-data","marine-resources","microservice","php-weather","storm","stormglass","weather-api","weather-app","weather-conditions","weather-data","weather-forecast-application","weather-forecaster-webapp","webservice-client"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vijinho.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-10-11T02:21:07.000Z","updated_at":"2020-08-19T14:24:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"2b7bb8fe-7fd0-48b6-9198-876bb7a9f2e5","html_url":"https://github.com/vijinho/stormyglass","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijinho%2Fstormyglass","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijinho%2Fstormyglass/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijinho%2Fstormyglass/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijinho%2Fstormyglass/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vijinho","download_url":"https://codeload.github.com/vijinho/stormyglass/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238845334,"owners_count":19540326,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json-api","marine-data","marine-resources","microservice","php-weather","storm","stormglass","weather-api","weather-app","weather-conditions","weather-data","weather-forecast-application","weather-forecaster-webapp","webservice-client"],"created_at":"2024-10-10T18:32:11.073Z","updated_at":"2025-10-29T15:31:16.209Z","avatar_url":"https://github.com/vijinho.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stormyglass  - a command-line php script for Storm Glass - The Global Marine Weather Forecast API\n\nCLI script `stormyglass.php` calls the [stormglass weather API](https://docs.stormglass.io/) and writes the JSON to a file if successful. Optionally will output the result to *stdout*.\n\nThe script can also be run as a web-service with PHP's in-built webserver for testing the JSON request/responses.\n\n## Features\n\n- Runs on the command-line\n- Uses a simple [stormyglass.ini](stormyglass.ini.dist) configuration file for options\n- Uses command-line [curl](https://curl.haxx.se)\n- Can be called as a stand-alone webservice using the php command line built-in server\n- Validates parameters before sending\n- Provided with global city data (populations \u003e 15000) from http://download.geonames.org/export/dump/ (cities15000.zip) listed/saved as JSON using --cities option, see also [data/cities15000.txt](data/cities15000.txt)\n- When calling with a city-id, adds the city information to the 'meta' information returned in the JSON result\n- Option to search for city information with --search-city\n- Caches the result (json-encoded) to avoiding sending repeat-requests with configurable cache age time (in seconds)\n- Cache filename is human-readable - format is: keys-values ie. *cache/lat-lng-57.7333333_10.6.json*\n- Option to return results averaged-out across sources\n- All messages when running with `--debug` or `--verbose` are to *stderr* to avoid interference with *stdout*\n- Can output the result if successful to *stdout*\n- Errors are output in JSON as 'errors' with just a bunch of strings with each error message as opposed to errors =\u003e param =\u003e array(0 =\u003e error) format, e.g.:\n\n```\n{\n    \"errors\": [\n        \"Unknown param(s) specified: 'humiditys'. Must be at least one of (airPressure, airTemperature, cloudCover, currentDirection, currentSpeed, gust, humidity, precipitation, seaLevel, swellDirection, swellHeight, swellPeriod, visiblity, waterTemperature, waveDirection, waveHeight, wavePeriod, windDirection, windSpeed, windWaveDirection, windWaveHeight, windWavePeriod)\"\n    ]\n}\n```\n\n## Returned results fields/columns/keys\n\n- time - Timestamp in UTC\n- airTemperature - Air temperature in degrees celsius\n- airPressure - Air pressure in hPa\n- cloudCover - Total cloud coverage in percent\n- currentDirection -Direction of current.\n- currentSpeed - Speed of current in meters per second.\n- gust - Wind gust in m/s\n- humidity - Relative humidity in percent\n- iceCover - Proportion, 0-1\n- precipitation - Mean precipitation in kg/m²\n- seaLevel - Height of sea level in MLLW (tides).\n- snowDepth - Depth of snow in meters\n- swellDirection - Direction of swell waves. 0° indicates swell coming from north\n- swellHeight - Height of swell waves in meters\n- swellPeriod - Period of swell waves in seconds\n- visiblity\tHorizontal - visibility in km\n- waterTemperature - Water temperature in degrees celsius\n- waveDirection - Direction of combined wind and swell waves. 0° indicates waves coming from north\n- waveHeight - Height of combined wind and swell waves\n- wavePeriod - Period of combined wind and swell waves\n- windWaveDirection - Direction of wind waves. 0° indicates waves coming from north\n- windWaveHeight - Height of wind waves\n- windWavePeriod - Period of wind waves\n- windDirection\t- Direction of wind. 0° indicates wind coming from north\n- windSpeed\t- Speed of wind in meters per second\n\n## Instructions\n\n### Command-line options\n\n```\nUsage: php stormyglass.php\nCall to the stormglass API - https://docs.stormglass.io\n(Specifying any other unknown argument options will be ignored.)\n\n        -h,  --help                   Display this help and exit\n        -v,  --verbose                Run in verbose mode\n        -d,  --debug                  Run in debug mode (implies also -v, --verbose)\n        -t,  --test                   Run in test mode, using co-ordinates for Skagen, Denmark from stormyglass.ini file by default.\n        -o,  --offline                Do not go-online when performing tasks (only use local files for url resolution for example)\n        -e,  --echo                   (Optional) Echo/output the result to stdout if successful\n             --cities                 List known cities with id, names and geolocation co-ordinates then exit.\n             --search-city=\u003ctext\u003e     Search for city using supplied text.\n        -r,  --refresh                (Optional) Force cache-refresh\n        -k,  --key={api key}          (Required) Stormglass API key (loaded from stormyglass.ini if not set)'\n             --city-id={city_id}      (Optional) Specify GeoNames city id (in cities.json file) for required latitude/longitude values\n             --latitude={-90 - 90}    (Required) Latitude (decimal degrees)\n             --longitude={-180 - 180} (Required) Longitude (decimal degrees)\n             --source={all}           (Optional) Source. Default: 'all'.  One of (all, dwd, fcoo, fmi, meteo, meto, noaa, sg, smhi, wt, yr)\n             --params={}              (Optional) Param(s). Comma-separated. (airPressure, airTemperature, cloudCover, currentDirection, currentSpeed, gust, humidity, precipitation, seaLevel, swellDirection, swellHeight, swellPeriod, visiblity, waterTemperature, waveDirection, waveHeight, wavePeriod, windDirection, windSpeed, windWaveDirection, windWaveHeight, windWavePeriod)\n             --date-from={now}        (Optional) Start date/time (at most 48 hours before current UTC), default 'today 00:00:00' see: https://secure.php.net/manual/en/function.strtotime.php\n             --date-to={all}          (Optional) End date/time for last forecast, default 'all' see: https://secure.php.net/manual/en/function.strtotime.php\n             --average                Return the average of the combined results from across the various sources.\n             --dir={}                 (Optional) Directory for storing files (sys_get_temp_dir() if not specified)\n        -f,  --filename={output.}     (Optional) Filename for output data from operation\n             --format={json}          (Optional) Output format for output filename (reserved for future): json (default)\n```\n\n### Requirements/Installation\n\n- An API key [from stormglass](https://stormglass.io/) (free sign-up is 50 request/daily)\n- PHP7\n- curl (command-line)\n- Copy the `stormyglass.ini.dist` to `stormyglass.ini` and add your API key there.\n- Run `php stormyglass.php --cities` to generate temp file `cities.json` file from `data/cities15000.tsv`\n\n## Testing Example\n\nRun the following to run the test and view in 'less' text viewer:\n\n`php stormyglass.php --debug --test 2\u003e\u00261 | less`\n\nThis will use the default co-ordinates of Skagen, Denmark and if successful will write-out a json file to the `cache` directory.\n\nRunning the same command-line again will retrieve the data from the cached file, e.g. this, which will write the result also to a file called `skagen.json`\n\n`php stormyglass.php --verbose --filename=skagen.json --test 2\u003e\u00261 | less`\n\nOutput result to *stdout*\n\n`php stormyglass.php --filename=skagen.json --test --echo`\n\nOutput the result to *stdout*, view messages whilst running, and redirect to into another file:\n\n`php stormyglass.php --filename=skagen.json --test --debug --echo 2\u003e\u00261 \u003emyfile.json`\n\n## Search city example\n\n`php stormyglass.php --echo --search-city=birmingham`\n\nResults:\n\n```\n{\n    \"2655603\": {\n        \"id\": 2655603,\n        \"country_code\": \"GB\",\n        \"state\": \"ENG\",\n        \"city\": \"Birmingham\",\n        \"ascii\": \"Birmingham\",\n        \"names\": [\n            \"BHX\",\n            \"Birmin'gxam\",\n            \"Birmingam\",\n            \"Birmingamas\",\n            \"Birmingem\",\n            \"Birmingema\",\n            \"Birmingham\",\n            \"Birminghamia\",\n            \"Birminghem\",\n            \"Gorad Birmingem\",\n            \"Mpermincham\",\n            \"bamingamu\",\n            \"barming'hyam\",\n            \"barmingahama\",\n            \"barmingahema\",\n            \"barmingham\",\n            \"barminghama\",\n            \"beoming-eom\",\n            \"birmingemi\",\n            \"bo ming han\",\n            \"bo ming han shi\",\n            \"brmngm\",\n            \"brmynghham\",\n            \"byrmngam\",\n            \"parminkam\"\n        ],\n        \"latitude\": 52.48142,\n        \"longitude\": -1.89983,\n        \"elevation\": 149,\n        \"population\": null,\n        \"timezone\": \"Europe\\/London\"\n    },\n    \"4049979\": {\n        \"id\": 4049979,\n        \"country_code\": \"US\",\n        \"state\": \"AL\",\n        \"city\": \"Birmingham\",\n        \"ascii\": \"Birmingham\",\n        \"names\": [\n            \"BHM\",\n            \"Bermincham\",\n            \"Bermingkham\",\n            \"Birmingam\",\n            \"Birmingamas\",\n            \"Birmingem\",\n            \"Birmingema\",\n            \"Birmingham\",\n            \"Birmingham i Alabama\",\n            \"Birminhem\",\n            \"Gorad Birmingem\",\n            \"baminguhamu\",\n            \"baminhamu\",\n            \"barmingahema\",\n            \"barmingahyama\",\n            \"beominghaem\",\n            \"birmingemi\",\n            \"bo ming han\",\n            \"brmnghham\",\n            \"brmyngm  alabama\",\n            \"parminkam\"\n        ],\n        \"latitude\": 33.52066,\n        \"longitude\": -86.80249,\n        \"elevation\": 187,\n        \"population\": 187,\n        \"timezone\": \"America\\/Chicago\"\n    },\n    \"4986172\": {\n        \"id\": 4986172,\n        \"country_code\": \"US\",\n        \"state\": \"MI\",\n        \"city\": \"Birmingham\",\n        \"ascii\": \"Birmingham\",\n        \"names\": [\n            \"Bermingkham\",\n            \"Birmingem\",\n            \"Birmingkham\",\n            \"brmnghham\",\n            \"byrmngam  myshygan\"\n        ],\n        \"latitude\": 42.5467,\n        \"longitude\": -83.21132,\n        \"elevation\": 241,\n        \"population\": 237,\n        \"timezone\": \"America\\/Detroit\"\n    }\n}\n\n```\n\n## Test using averaged-out results\n\nReturn averaged-out results across sources, using 'unixtime' as the index for 'hours'\n\n`php stormyglass.php --debug --test --average`\n\n```\n{\n    \"hours\": {\n        \"1539302400\": {\n            \"airTemperature\": 13,\n            \"cloudCover\": 0,\n            \"currentDirection\": 230,\n            \"currentSpeed\": 0,\n            \"gust\": 10,\n            \"humidity\": 85,\n            \"precipitation\": 0,\n            \"pressure\": 1016,\n            \"seaLevel\": 0,\n            \"swellDirection\": 182,\n            \"swellHeight\": 0,\n            \"swellPeriod\": 3,\n            \"time\": \"2018-10-12T00:00:00+00:00\",\n            \"visibility\": 26,\n            \"waterTemperature\": 11,\n            \"waveDirection\": 134,\n            \"waveHeight\": 1,\n            \"wavePeriod\": 3,\n            \"windDirection\": 144,\n            \"windSpeed\": 6,\n            \"windWaveDirection\": 138,\n            \"windWaveHeight\": 1,\n            \"windWavePeriod\": 3,\n            \"unixtime\": 1539302400\n        },\n        \"1539306000\": {\n            \"airTemperature\": 13,\n            \"cloudCover\": 0,\n            \"currentDirection\": 220,\n            \"currentSpeed\": 0,\n            \"gust\": 9,\n            \"humidity\": 86,\n            \"precipitation\": 0,\n            \"pressure\": 1017,\n            \"seaLevel\": 0,\n            \"swellDirection\": 161,\n            \"swellHeight\": 0,\n            \"swellPeriod\": 3,\n            \"time\": \"2018-10-12T01:00:00+00:00\",\n            \"visibility\": 25,\n            \"waterTemperature\": 11,\n            \"waveDirection\": 134,\n            \"waveHeight\": 1,\n            \"wavePeriod\": 3,\n            \"windDirection\": 150,\n            \"windSpeed\": 5,\n            \"windWaveDirection\": 138,\n            \"windWaveHeight\": 1,\n            \"windWavePeriod\": 3,\n            \"unixtime\": 1539306000\n        },\n\u003c!--- SNIP ---\u003e\n    },\n    \"meta\": {\n        \"cost\": 1,\n        \"dailyQuota\": 50,\n        \"end\": \"2018-10-22 00:00\",\n        \"lat\": 57,\n        \"lng\": 10,\n        \"params\": [\n            \"waterTemperature\",\n            \"wavePeriod\",\n            \"waveDirection\",\n            \"waveDirection\",\n            \"waveHeight\",\n            \"windWaveDirection\",\n            \"windWaveHeight\",\n            \"windWavePeriod\",\n            \"swellPeriod\",\n            \"swellDirection\",\n            \"swellHeight\",\n            \"windSpeed\",\n            \"windDirection\",\n            \"airTemperature\",\n            \"precipitation\",\n            \"gust\",\n            \"cloudCover\",\n            \"humidity\",\n            \"pressure\",\n            \"visibility\",\n            \"seaLevel\",\n            \"currentSpeed\",\n            \"currentDirection\"\n        ],\n        \"requestCount\": 5,\n        \"start\": \"2018-10-12 00:00\"\n    }\n}\n```\n\n## Test example using GeoNames City ID\n\nSearches for city with ID '8349222'\n\n```\nphp stormyglass.php --city-id=8349222 --debug\n```\n\nDebug data of city result:\n\n```\nArray\n(\n    [8349222] =\u003e Array\n        (\n            [id] =\u003e 8349222\n            [country_code] =\u003e AU\n            [state] =\u003e 2\n            [city] =\u003e Punchbowl\n            [ascii] =\u003e Punchbowl\n            [names] =\u003e Array\n                (\n                    [0] =\u003e\n                )\n\n            [latitude] =\u003e -33.92893\n            [longitude] =\u003e 151.05111\n            [elevation] =\u003e 19\n            [population] =\u003e\n            [timezone] =\u003e Australia/Sydney\n        )\n\n)\n```\n\nData saved in: `cache/lat-lng--33.92893_151.05111.json`\n\n## Test example using GeoNames CityID and data from today until next Sunday\n\nThis will search the data for Barcelona (city id 3128760) from today (00:00) until 'next Sunday (00:00)', save the result to 'barcelona.json' and also echo the output and debug information, piping it into 'less' to view on the command line.\n\n`php stormyglass.php --city-id=3128760 --average --filename=barcelona.json --date-from=today --date-to='next sunday' --echo --debug 2\u003e\u00261 | less`\n\n\n## Offline mode debugging example\n\nAn example for debugging - get the wave-height and humidity for Liverpool, UK using data from The Met Office for yesterday 7am until next thursday, 2230 and display the request that would be sent:\n\n`php stormyglass.php --debug --filename=liverpool.json --source=met --latitude=53.416667 --longitude=-2.9779400 --params=waveHeight,humidity --date-from='yesterday, 7am' --date-to='next Friday, 2230' --echo 2\u003e\u00261 | less`\n\nNote the *V* is (--verbose) mode output, and the *D* is (--debug) mode output, and the numbers following in format 9/9 are memory (used/peak memory used) in script\n\nResult:\n\n```\n[D 1/1] CONFIG\nArray\n(\n    [timezone] =\u003e UTC\n    [cache] =\u003e Array\n        (\n            [seconds] =\u003e 86400\n        )\n\n    [key] =\u003e **\u003cAPI_KEY\u003e**\n    [url] =\u003e Array\n        (\n            [point] =\u003e https://api.stormglass.io/point\n            [area] =\u003e https://api.stormglass.io/area\n        )\n\n    [sources] =\u003e Array\n        (\n            [0] =\u003e all\n            [1] =\u003e dwd\n            [2] =\u003e fcoo\n            [3] =\u003e fmi\n            [4] =\u003e meteo\n            [5] =\u003e meto\n            [6] =\u003e noaa\n            [7] =\u003e sg\n            [8] =\u003e smhi\n            [9] =\u003e wt\n            [10] =\u003e yr\n        )\n\n    [params] =\u003e Array\n        (\n            [0] =\u003e airPressure\n            [1] =\u003e airTemperature\n            [2] =\u003e cloudCover\n            [3] =\u003e currentDirection\n            [4] =\u003e currentSpeed\n            [5] =\u003e gust\n            [6] =\u003e humidity\n            [7] =\u003e precipitation\n            [8] =\u003e seaLevel\n            [9] =\u003e swellDirection\n            [10] =\u003e swellHeight\n            [11] =\u003e swellPeriod\n            [12] =\u003e visiblity\n            [13] =\u003e waterTemperature\n            [14] =\u003e waveDirection\n            [15] =\u003e waveHeight\n            [16] =\u003e wavePeriod\n            [17] =\u003e windDirection\n            [18] =\u003e windSpeed\n            [18] =\u003e windSpeed\n            [19] =\u003e windWaveDirection\n            [20] =\u003e windWaveHeight\n            [21] =\u003e windWavePeriod\n        )\n\n    [latitude] =\u003e 57.7333333\n    [longitude] =\u003e 10.6\n)\n[D 1/1] COMMANDS:\nArray\n(\n    [curl] =\u003e /usr/local/bin/curl\n)\n[D 1/1] OPTIONS:\nArray\n(\n    [debug] =\u003e 1\n    [echo] =\u003e 1\n    [offline] =\u003e 1\n    [test] =\u003e 0\n    [verbose] =\u003e 1\n)\n[V 1/1] OUTPUT_FORMAT: json\n[D 1/1] Using API key: **\u003cAPI_KEY\u003e**\n[V 1/1] Latitude: 53.416667\n[V 1/1] Longitude: -2.97794\n[V 1/1] Param(s):\nArray\n(\n    [0] =\u003e waveHeight\n    [1] =\u003e humidity\n)\n[V 1/1] Filtering tweets FROM date/time 'yesterday, 7am': Wed, 10 Oct 2018 07:00:00 +0000\n[V 1/1] Filtering tweets TO date/time 'next Friday, 2230': Fri, 12 Oct 2018 22:30:00 +0000\n[V 1/1] Request params:\nArray\n(\n    [lat] =\u003e 53.416667\n    [lng] =\u003e -2.97794\n    [params] =\u003e waveHeight,humidity\n    [start] =\u003e 2018-10-10T07:00:00+00:00\n    [end] =\u003e 2018-10-12T22:30:00+00:00\n)\n[D 1/1] Cached file data not found for: /Users/vijay/src/stormyglass/cache/e5afc408fd978d2a46783cc3f770fdcf1821ec5b.json\n[D 1/1] OFFLINE MODE! Can't request:\n        curl -H \"Authorization: **\u003cAPI_KEY\u003e**\" --connect-timeout 3 --max-time 30 --ciphers ALL -k -L -s 'https://api.stormglass.io/point?lat=53.416667\u0026lng=-2.97794\u0026params=waveHeight%2Chumidity\u0026start=2018-10-10T07%3A00%3A00%2B00%3A00\u0026end=2018-10-12T22%3A30%3A00%2B00%3A00'\n\nError(s):\n        - Request failed:\n```\n\nThe request obviously failed because we used `--offline`! Remove it to actually perform the request.\n\nThe actual result:\n\n```\n{\n    \"hours\": [\n        {\n            \"humidity\": [\n                {\n                    \"source\": \"sg\",\n                    \"value\": 89.98\n                },\n                {\n                    \"source\": \"noaa\",\n                    \"value\": 94.16\n                },\n                {\n                    \"source\": \"wrf\",\n                    \"value\": 73.94\n                },\n                {\n                    \"source\": \"dwd\",\n                    \"value\": 89.98\n                }\n            ],\n            \"time\": \"2018-10-10T07:00:00+00:00\",\n            \"waveHeight\": [\n                {\n                    \"source\": \"sg\",\n                    \"value\": 0.3\n                },\n                {\n                    \"source\": \"meto\",\n                    \"value\": 0.3\n                },\n                {\n                    \"source\": \"dwd\",\n                    \"value\": 0.25\n                },\n                {\n                    \"source\": \"meteo\",\n                    \"value\": 0.3\n                }\n            ]\n        },\n\u003c---- SNIP!!! ----\u003e\n    ],\n    \"meta\": {\n        \"cost\": 1,\n        \"dailyQuota\": 50,\n        \"end\": \"2018-10-12 22:30\",\n        \"lat\": 53.416667,\n        \"lng\": -2.97794,\n        \"params\": [\n            \"waveHeight\",\n            \"humidity\"\n        ],\n        \"requestCount\": 14,\n        \"start\": \"2018-10-10 07:00\"\n    }\n}\n```\n\n## Updating cities list\n\n- Go to [http://download.geonames.org/export/dump/](http://download.geonames.org/export/dump/)\n- Download [cities15000.zip](http://download.geonames.org/export/dump/cities15000.zip)\n- Unzip and save to [data/cities.tsv](data/cities.tsv)\n- Run script with '-r' to refresh cache and '--cities' to re-create [cache/cities.json](cache/cities.json)\n\n## Running as a webservice\n\n### Starting the service\n1. Start the PHP webserver with `php -S 127.0.0.1:12312`\n2. Browse the URL: http://127.0.0.1:12312/stormyglass.php with GET/POST parameters as required.\n\n*NOTE:* The webservice only allows the following parameters which will be filtered and passed to the command-line script:\n\n- 'key'\n- 'date-from'\n- 'date-to'\n- 'latitude'\n- 'longitude'\n- 'source'\n- 'params'\n- 'refresh'\n- 'cities'\n- 'city-id'\n- 'search-city'\n- 'average'\n\n### Webservice Example 1\n\ne.g. For -id 999999 http://127.0.0.1:12312/stormyglass.php?city-id=999999\n\nhttp://127.0.0.1:12312/stormyglass.php?city-id=999999\n\nReturns:\n\n```\n{\n    \"errors\": [\n        \"City not found with id: 292672222\"\n    ]\n}\n```\n\n### Webservice Example 2\n\nSearch for city 'wolverhampton'\n\nhttp://127.0.0.1:12312/stormyglass.php?search-city=wolverhampton\n\nResult:\n\n```\n{\n    \"2633691\": {\n        \"id\": 2633691,\n        \"country_code\": \"GB\",\n        \"state\": \"ENG\",\n        \"city\": \"Wolverhampton\",\n        \"ascii\": \"Wolverhampton\",\n        \"names\": [\n            \"Goulverchampton\",\n            \"Heantun\",\n            \"Ulvurkhamptun\",\n            \"Vulvergempton\",\n            \"Vulverhamptonas\",\n            \"Vulverhempton\",\n            \"Vulverhemptona\",\n            \"Vulverkhempton\",\n            \"Wolverhampton\",\n            \"Wulfrunehantona\",\n            \"XVW\",\n            \"ulbeohaempeuteon\",\n            \"u~oruvu~ahanputon\",\n            \"wlwrhmptwn\",\n            \"wu er fu han pu dun\",\n            \"wwlbrhmptwn\",\n            \"wwlfrhambtwn\",\n            \"\\u0393\\u03bf\\u03c5\\u03bb\\u03b2\\u03b5\\u03c1\\u03c7\\u03ac\\u03bc\\u03c0\\u03c4\\u03bf\\u03bd\",\n            \"\\u0412\\u0443\\u043b\\u0432\\u0435\\u0440\\u0433\\u0435\\u043c\\u043f\\u0442\\u043e\\u043d\",\n            \"\\u0412\\u0443\\u043b\\u0432\\u0435\\u0440\\u0445\\u0435\\u043c\\u043f\\u0442\\u043e\\u043d\",\n            \"\\u0423\\u043b\\u0432\\u044a\\u0440\\u0445\\u0430\\u043c\\u043f\\u0442\\u044a\\u043d\",\n            \"\\u054e\\u0578\\u0582\\u056c\\u057e\\u0565\\u0580\\u0570\\u0565\\u0574\\u057a\\u057f\\u0578\\u0576\",\n            \"\\u05d5\\u05d5\\u05d0\\u05dc\\u05d5\\u05d5\\u05e2\\u05e8\\u05d4\\u05d0\\u05de\\u05e4\\u05d8\\u05d0\\u05df\",\n            \"\\u05d5\\u05d5\\u05dc\\u05d1\\u05e8\\u05d4\\u05de\\u05e4\\u05d8\\u05d5\\u05df\",\n            \"\\u0648\\u0644\\u0648\\u0631\\u0647\\u0645\\u067e\\u062a\\u0648\\u0646\",\n            \"\\u0648\\u0648\\u0644\\u0641\\u0631\\u0647\\u0627\\u0645\\u0628\\u062a\\u0648\\u0646\",\n            \"\\u0648\\u0648\\u0644\\u0648\\u0631\\u06c1\\u06cc\\u0645\\u067e\\u0679\\u0646\",\n            \"\\u0e27\\u0e38\\u0e25\\u0e40\\u0e27\\u0e2d\\u0e23\\u0e4c\\u0e41\\u0e2e\\u0e21\\u0e1b\\u0e4c\\u0e15\\u0e31\\u0e19\",\n            \"\\u10d5\\u10e3\\u10da\\u10d5\\u10d4\\u10e0\\u10f0\\u10d4\\u10db\\u10de\\u10e2\\u10dd\\u10dc\\u10d8\",\n            \"\\u30a6\\u30a9\\u30eb\\u30f4\\u30a1\\u30fc\\u30cf\\u30f3\\u30d7\\u30c8\\u30f3\",\n            \"\\u4f0d\\u723e\\u5f17\\u6f22\\u666e\\u9813\",\n            \"\\uc6b8\\ubc84\\ud584\\ud504\\ud134\"\n        ],\n        \"latitude\": 52.58547,\n        \"longitude\": -2.12296,\n        \"elevation\": 160,\n        \"population\": null,\n        \"timezone\": \"Europe\\/London\"\n    }\n}\n```\n\nThe ID 2633691 can then be used to fetch the data for that city.\n\n\n### Webservice Example 3\n\nGet averaged-out results from the web-service for city 1120985:\n\nhttp://127.0.0.1:12312/stormyglass.php?city-id=1120985\u0026average\n\nResults:\n\n```\n{\n    \"hours\": {\n        \"1539388800\": {\n            \"airTemperature\": 21.07,\n            \"cloudCover\": 0,\n            \"currentDirection\": 0,\n            \"currentSpeed\": 0,\n            \"gust\": 5.88,\n            \"humidity\": 14.35,\n            \"precipitation\": 0,\n            \"pressure\": 1014.57,\n            \"seaLevel\": 0,\n            \"swellDirection\": 0,\n            \"swellHeight\": 0,\n            \"swellPeriod\": 0,\n            \"time\": \"2018-10-13T00:00:00+00:00\",\n            \"visibility\": 24.1,\n            \"waterTemperature\": 18.55,\n            \"waveDirection\": 0,\n            \"waveHeight\": 0,\n            \"wavePeriod\": 0,\n            \"windDirection\": 0,\n            \"windSpeed\": 0,\n            \"windWaveDirection\": 0,\n            \"windWaveHeight\": 0,\n            \"windWavePeriod\": 0,\n            \"unixtime\": 1539388800\n        },\n\u003c!--- SNIP ---\u003e\n    \"meta\": {\n        \"cost\": 1,\n        \"dailyQuota\": 50,\n        \"end\": \"2018-10-23 00:00\",\n        \"lat\": 30.95962,\n        \"lng\": 61.86037,\n        \"params\": [\n            \"airTemperature\",\n            \"cloudCover\",\n            \"currentDirection\",\n            \"currentSpeed\",\n            \"gust\",\n            \"humidity\",\n            \"precipitation\",\n            \"pressure\",\n            \"seaLevel\",\n            \"swellDirection\",\n            \"swellHeight\",\n            \"swellPeriod\",\n            \"visibility\",\n            \"waterTemperature\",\n            \"waveDirection\",\n            \"waveDirection\",\n            \"waveHeight\",\n            \"wavePeriod\",\n            \"windDirection\",\n            \"windSpeed\",\n            \"windWaveDirection\",\n            \"windWaveHeight\",\n            \"windWavePeriod\"\n        ],\n        \"requestCount\": 4,\n        \"start\": \"2018-10-13 00:00\",\n        \"city\": {\n            \"id\": 1120985,\n            \"country_code\": \"AF\",\n            \"state\": 19,\n            \"city\": \"Zaranj\",\n            \"ascii\": \"Zaranj\",\n            \"names\": [\n                \"Sarandsch\",\n                \"ZAJ\",\n                \"Zaranas\",\n                \"Zarandj\",\n                \"Zarandz\",\n                \"Zarandzas\",\n                \"Zarandzh\",\n                \"Zarand\\u017c\",\n                \"Zarand\\u017eas\",\n                \"Zarang\",\n                \"Zarani\",\n                \"Zaranj\",\n                \"Zaran\\u011d\",\n                \"Zerenc\",\n                \"Zhazang\",\n                \"Z\\u0259r\\u0259nc\",\n                \"zaranja\",\n                \"zha lan ji\",\n                \"zrnj\",\n                \"\\u0417\\u0430\\u0440\\u0430\\u043d\\u0434\\u0436\",\n                \"\\u0417\\u0430\\u0440\\u0430\\u043d\\u0438\",\n                \"\\u0417\\u0430\\u0440\\u0430\\u043d\\u04b7\",\n                \"\\u0632\\u0631\\u0646\\u062c\",\n                \"\\u091c\\u093c\\u0930\\u0902\\u091c\",\n                \"\\u624e\\u5170\\u5b63\"\n            ],\n            \"latitude\": 30.95962,\n            \"longitude\": 61.86037,\n            \"elevation\": 489,\n            \"population\": null,\n            \"timezone\": \"Asia\\/Kabul\"\n        }\n    }\n}\n```\n\n\n## See also\n\n- [stormglass dashboard](https://dashboard.stormglass.io)\n\n## To do\n\n- [Area Request](https://docs.stormglass.io/?shell#area-request) - not yet implemented due to limited API account (uses up requests!)\n\n--\nvijay@yoyo.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvijinho%2Fstormyglass","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvijinho%2Fstormyglass","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvijinho%2Fstormyglass/lists"}