TGViewer
Learn Python Coding Learn Python Coding @pythonre · 40.8K subscribers
Post #8919 1.48K
Create a simple weather parser that displays the current temperature and weather conditions from a free API

We will write a script that retrieves weather data for your city and displays it in a convenient format.

First, we need the requests library for network operations. If it's not installed, install it via the terminal with the command:
pip install requests


Import the module and define a function that retrieves data from the Open-Meteo API (no key required) for specific coordinates:
import requests

def get_weather(lat, lon):
    url = f"https://api.open-meteo.com/v1/forecast?latitude={lat}&longitude={lon}&current_weather=true"
    return requests.get(url).json()['current_weather']


Specify the coordinates of your city (for example, Moscow):
moscow_coords = (55.75, 37.62)

Display the temperature and wind speed:
weather = get_weather(*moscow_coords)
print(f"Temperature: {weather['temperature']}°C, Wind speed: {weather['windspeed']} km/h")


🔥 Get fresh weather data without registration or passwords — useful for your own projects or bots!

🚪 @DataScience4
  • ❤ 3
More from @pythonre
  1. Oct 13, 2026https://substack.com/@husseinsheikho?utm_source=share&utm_medium=android&r=3hwnr8 Follow m…
  2. Oct 10, 2026📚 Download 10 Python books for FREE: 1. Think Python — O’Reilly https://t.co/X7y3pX68IW 2…
  3. Oct 7, 2026Python Lists: A Quick Reference 🐍 * Definition: Lists are ordered, mutable collections th…
  4. Oct 7, 2026📱 270 tools for Python developers The repository contains: 🫡 Linters and formatters; 🫡…
  5. Oct 7, 2026Hands On Python Data Science - Data Science Bootcamp Master Python for Data Science with R…
  6. Oct 6, 2026Post #9851
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →