{"id":18980375,"url":"https://github.com/pierreamgabriel/react-native-weather-api","last_synced_at":"2025-04-19T19:05:20.604Z","repository":{"id":57341371,"uuid":"148191859","full_name":"pierreamgabriel/react-native-weather-api","owner":"pierreamgabriel","description":"Real-time weather information for any location on Earth, including over 200,000 cities.","archived":false,"fork":false,"pushed_at":"2024-11-17T22:03:50.000Z","size":750,"stargazers_count":13,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T12:03:57.418Z","etag":null,"topics":["react-native","weather-api"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pierreamgabriel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-09-10T17:18:30.000Z","updated_at":"2024-11-17T22:03:54.000Z","dependencies_parsed_at":"2023-02-08T14:31:06.308Z","dependency_job_id":"a8293091-8f2c-4bc9-8a4d-9b09c6cc7bf7","html_url":"https://github.com/pierreamgabriel/react-native-weather-api","commit_stats":{"total_commits":25,"total_committers":3,"mean_commits":8.333333333333334,"dds":0.12,"last_synced_commit":"91964416108390f28a52f2d486d93d83158d6796"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreamgabriel%2Freact-native-weather-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreamgabriel%2Freact-native-weather-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreamgabriel%2Freact-native-weather-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreamgabriel%2Freact-native-weather-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pierreamgabriel","download_url":"https://codeload.github.com/pierreamgabriel/react-native-weather-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248975299,"owners_count":21192199,"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":["react-native","weather-api"],"created_at":"2024-11-08T16:06:41.206Z","updated_at":"2025-04-16T12:31:06.762Z","avatar_url":"https://github.com/pierreamgabriel.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Native Weather API\n\nReal-time weather information for any location on Earth, including over 200,000 cities.\n\n## Installation\n\n```bash\nnpm install react-native-weather-api\n```\nYou must also install @react-native-community/geolocation:\n\n```bash\nnpm install @react-native-community/geolocation\n```\n\n## Permission\n\n**Android**\n\nTo request access to location, you need to add the following line to your app's AndroidManifest.xml:\n\n```xml\n\u003cuses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" /\u003e\n```\n\n**iOS**\n\nYou need to include the `NSLocationWhenInUseUsageDescription` key in Info.plist to enable geolocation when using the app. Geolocation is enabled by default when you create a project with `react-native init`.\n\n## Usage\n\nThis plugin uses the OpenWeather API to show weather information, so you need to create an account on https://openweathermap.org and get your key. Free accounts are allowed to perform 1,000,000 calls/month and 60 calls/minute.\n\n### Import the plugin\n\n```javascript\nimport { getWeather, dailyForecast, showWeather, getLocation } from 'react-native-weather-api';\n```\n\n### API calls \n\n**By geographic coordinates**\n\nWhen using coordinates, you can't pass the city and ZIP code parameters.\n\n```javascript\nlet temp;\nlet wind;\n\ngetLocation().then((location) =\u003e {\n\t\t\t\ngetWeather({\n\n\tkey: \"your_key\",\n\tlat: location.coords.latitude,\n\tlon: location.coords.longitude,\n\tunit: \"metric\"\n\n}).then(() =\u003e {\n\n\tlet data = new showWeather();\n\ttemp = data.temp;\n\twind = data.wind;\n});\n\n});\n```\n\n**By city name**\n\nWhen calling by city name, you can't pass the latitude, longitude, and ZIP code parameters.\n\n```javascript\nlet temp;\nlet wind;\n\ngetWeather({\n\t\t\t\n\tkey: \"your_key\",\n\tcity: \"London\",\n\tcountry: \"GB\"\n\n}).then(() =\u003e {\n\n\tlet data = new showWeather();\n\ttemp = data.temp;\n\twind = data.wind;\n});\n```\n\n**By ZIP code**\n\nThis method doesn't seem to work with all countries. For example, the API didn't recognize ZIP codes from Brazil during my tests.\n\nDon't pass the latitude, longitude, and city parameters.\n\n```javascript\nlet temp;\nlet wind;\n\ngetWeather({\n\t\t\t\n\tkey: \"your_key\",\n\tzip_code: \"90001\",\n\tcountry: \"US\"\n\n}).then(() =\u003e {\n\n\tlet data = new showWeather();\n\ttemp = data.temp;\n\twind = data.wind;\n});\n```\n\n## Parameters\n\n`key` - Your OpenWeather key.\u003cbr\u003e \n`lat` - Latitude.\u003cbr\u003e \n`lon` - Longitude.\u003cbr\u003e \n`city` - City name, e.g., Los Angeles.\u003cbr\u003e \n`country` - Country code, e.g., US, CA, GB.\u003cbr\u003e \n`zip_code` - Numeric or alphanumeric codes, e.g., 90001.\u003cbr\u003e\n`unit` - If you set it to `metric`, the temperature will be in Celsius and wind speed in meter/s. If you choose `imperial`, the temperature will be in Fahrenheit and wind speed in miles/h. If you don't set this parameter, Kelvin and meter/s are the standards.\u003cbr\u003e\n`lang` - The output language for the city name and description fields, e.g., en, pt_br, fr, es.\n\n## Identifiers\n\n`name` - Location name.\u003cbr\u003e\n`country` - Country name.\u003cbr\u003e\n`temp` - Temperature.\u003cbr\u003e\n`temp_min` - Minimum temperature.\u003cbr\u003e\n`temp_max` - Maximum temperature.\u003cbr\u003e\n`feels_like` - Feels like temperature.\u003cbr\u003e\n`wind` - Wind speed.\u003cbr\u003e\n`pressure` - Pressure.\u003cbr\u003e\n`humidity` - Humidity.\u003cbr\u003e\n`description` - Weather description, e.g., clear sky.\u003cbr\u003e\n`icon` - Weather icon URL.\n\n## Daily forecast for 7 days\n\nWith only one call, you can get weather information for 7 days plus the current day. \n\n```javascript\nlet temp_min;\nlet temp_max;\nlet description;\n\ngetLocation().then((location) =\u003e {\n\t\t\t\ndailyForecast({\n\n\tkey: \"your_key\",\n\tlat: location.coords.latitude,\n\tlon: location.coords.longitude,\n\tunit: \"metric\"\n\n}).then((data) =\u003e {\n\n\ttemp_min = data.daily[0].temp.min;\n\ttemp_max = data.daily[0].temp.max;\n\tdescription = data.daily[0].weather[0].description;\n});\n\n});\n```\n\nThe `dailyForecast` function only accepts latitude and longitude to determine the location. In the example, we retrieved the minimum and maximum temperature and the weather description for the current day. If we wanted information for the following day, we'd change `daily[0]` to `daily[1]`, and so on up to `daily[7]`. To see all the fields available besides the ones we used in this section, create an `alert(JSON.stringify(data, null, 4))`, but don't forget to remove it before building for production.\n\n## 5 day / 3 hour forecast data\n\nForecast for 5 days with data every 3 hours.\n\n```javascript\nlet temp;\nlet description;\n\ngetLocation().then((location) =\u003e {\n\t\t\t\nfiveDaysForecast({\n\n\tkey: \"your_key\",\n\tlat: location.coords.latitude,\n\tlon: location.coords.longitude,\n\tunit: \"metric\"\n\n}).then((data) =\u003e {\n\n\ttemp = data.list[0].main.temp;\n\tdescription = data.list[0].weather[0].description;\n});\n\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierreamgabriel%2Freact-native-weather-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpierreamgabriel%2Freact-native-weather-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierreamgabriel%2Freact-native-weather-api/lists"}