Code examples for integrating WeatherAPI.com in popular languages and frameworks.
Sign up at weatherapi.com/signup.aspx — no credit card required. 100,000 calls/month free.
| Language / Framework | Directory | Description |
|---|---|---|
| JavaScript (Fetch) | javascript/ | Vanilla JS using the Fetch API |
| Node.js | nodejs/ | Node.js with axios |
| Python | python/ | Python with requests library |
| Python (Async) | python-async/ | Python with aiohttp |
| PHP | php/ | PHP with cURL |
| Ruby | ruby/ | Ruby with net/http |
| Go | go/ | Go with net/http |
| Java | java/ | Java with HttpClient |
| C# (.NET) | csharp/ | C# with HttpClient |
| Swift | swift/ | Swift with URLSession |
| Kotlin | kotlin/ | Kotlin with OkHttp |
| Rust | rust/ | Rust with reqwest |
| React | react/ | React hooks weather widget |
| Next.js | nextjs/ | Next.js API routes + SSR |
| Vue.js | vuejs/ | Vue 3 Composition API |
| Express.js | expressjs/ | Express.js REST proxy |
| Django | django/ | Django views + templates |
| Flask | flask/ | Flask REST API |
| Laravel | laravel/ | Laravel controller + blade |
| Spring Boot | spring-boot/ | Spring Boot REST controller |
| Claude AI (MCP) | mcp/ | Use WeatherAPI inside Claude |
WeatherAPI works natively with Claude and other AI assistants via MCP:
{
"mcpServers": {
"weatherapi": {
"command": "npx",
"args": ["-y", "weatherapi-mcp"],
"env": {
"WEATHERAPI_KEY": "your_api_key_here"
}
}
}
}See the mcp/ directory for full setup instructions.
Each example demonstrates:
- ✅ Current weather
- ✅ 3-day forecast
- ✅ Hourly breakdown
- ✅ Air quality index
- ✅ Weather alerts
- ✅ Location search
- ✅ Error handling
- ✅ Authentication
MIT — free to use in personal and commercial projects.
- Docs: weatherapi.com/docs
- Email: support@weatherapi.com
- Forum: weatherapi.com/forum