Skip to content

souravk29/Weather_Api_impl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fetched info from openWeatherMap Api in Rust Screenshot

Weather_Api_impl

A Rust implementation that consumes a weather API and exposes a simple, programmatic way to fetch current conditions (and optionally forecasts) for a given location.

Features

  • Written in Rust (100%)
  • Fetch current weather by city name or lat/long
  • Configurable via environment variables
  • Clean error handling and typed responses
  • Ready to run locally

Note: This README is a template since I don’t have the repository’s source/layout here. If you share the main entry file (e.g., src/main.rs) or the API/provider used, I can tailor this README exactly to your code, commands, and endpoints.

Requirements

Quick Start

1) Clone

git clone https://github.com/souravk29/Weather_Api_impl.git
cd Weather_Api_impl

2) Configure environment variables

Create a .env file in the project root (or export env vars in your shell):

WEATHER_API_KEY=your_api_key_here
# Optional (depends on your implementation/provider):
WEATHER_BASE_URL=https://api.openweathermap.org
WEATHER_UNITS=metric

If you use dotenvy/dotenv, the app will load .env automatically (if implemented).

3) Build & run

cargo build
cargo run

Usage

How you call the app depends on whether this is a CLI or a web server.

If this is a CLI

Examples (adjust flags to match your implementation):

cargo run -- --city "Kolkata"
cargo run -- --lat 22.5726 --lon 88.3639

If this is a web API (server)

Start the server:

cargo run

Then call an endpoint (example):

curl "http://localhost:8080/weather?city=Kolkata"

Configuration

Common configuration keys used in Rust weather clients:

  • WEATHER_API_KEY (required): API key for the provider
  • WEATHER_BASE_URL (optional): override provider base URL
  • WEATHER_UNITS (optional): metric, imperial, or provider-specific
  • RUST_LOG (optional): logging level, e.g. info, debug

Example:

export WEATHER_API_KEY="..."
export RUST_LOG=debug
cargo run

Project Structure (typical)

This is a suggested structure (may differ in your repo):

src/
  main.rs            # entry point
  lib.rs             # library interface (optional)
  client.rs          # HTTP client logic
  models.rs          # response structs
  config.rs          # env/config parsing

Development

Run formatting and linting:

cargo fmt
cargo clippy -- -D warnings

Run tests:

cargo test

Troubleshooting

  • 401/403 from provider: check WEATHER_API_KEY
  • Network/TLS issues: ensure your system cert store is up-to-date
  • Unexpected JSON parsing errors: provider response schema may differ; verify model structs match the API response

License

Add a license if you intend the repo to be reused:

  • MIT or Apache-2.0 are common for Rust projects.

Share details to make this README exact

If you paste:

  • the weather provider name (OpenWeatherMap / WeatherAPI / etc.)
  • whether it’s a CLI or server (and any endpoint paths/flags)
  • your crate dependencies (Cargo.toml)

…I can rewrite this README to match your repo precisely.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages