This repository contains the backend service for Wilson's Weather, a web application that provides real-time weather updates. This service handles requests to fetch weather data based on user location or a specific location input, using various APIs.
- Weather Data Fetching: Retrieves weather information using the OpenWeather API based on coordinates or IP address.
- Geolocation: Converts a user-provided address to geographic coordinates using Google's Geocoding API.
- IP-based Location Fetching: Determines the user's location from their IP address using the IPinfo API.
- OpenWeather API: For fetching current, hourly, and weekly weather data.
- Google Geocoding API: For translating addresses into geographic coordinates.
- IPinfo API: For obtaining location information from IP addresses.
- Clone the repository:
git clone https://github.com/yourgithubusername/weather-app-backend.git
- Navigate to the project directory:
cd weather-app-backend
- Install dependencies:
npm install
- Create a
.env
file and fill in your API keys:GOOGLE_MAPS_API_KEY=your_google_maps_api_key OPEN_WEATHER_API_KEY=your_openweather_api_key IP_INFO_API_KEY=your_ipinfo_api_key
- Start the server:
npm start
Ensure you have the following environment variables set up in your .env
file:
GOOGLE_MAPS_API_KEY
: API key for Google Maps services.OPEN_WEATHER_API_KEY
: API key for OpenWeather services.IP_INFO_API_KEY
: API key for IPinfo services.
To run the server, use:
npm start
This will start the server on the port specified in your .env
file or default to 3000.
/start-weather-data?coords=[latitude],[longitude]
: Returns weather data for specified coordinates./ip-weather-data
: Returns weather data based on the user's IP address./search-locations?input=[userInput]
: Returns autocomplete location suggestions based on user input./weather-data?input=[location]
: Returns weather data for a specified location.
Contributions to improve the backend are welcome. Please fork the repository and submit a pull request with your changes.