Computer Pro
Computer Pro
N.K. BLAHATIA
Principal
ACKNOWLEDGEMENT
1. Purpose of APIs:
Simplify development by allowing developers to use existing
functionalities or data from other applications.
Allow integration between software systems, devices, or
services.
http://api.openweathermap.org/data/2.5/weather?q=London&
appid=YOUR_API_KEY
Response:
{ “weather”: [{“description”: “clear sky”}],
“main”: {“temp”: 15.5, “humidity”: 40},
“wind”: {“speed”: 2.1}
}
• Request Methods:
GET: Retrieve data (e.g., get weather for a city).
POST: Send data to the server (e.g., submit a form).
PUT: Update data.
DELETE: Remove data.
3.Rate Limits: Restrict the number of requests to prevent
overuse.
2.Payment APIs:
Process payments securely (e.g., PayPal, Stripe).
3.Mapping APIs:
Provide directions or maps (e.g., Google Maps API).
• Key Features:
• Example:
import tkinter as tk
# Create the main window
root = tk.Tk()
root.title("Hello Tkinter")
# Add a label widget
label = tk.Label(root, text="Welcome to Tkinter!")
label.pack() # Automatically place the widget
# Add a button to close the window
button = tk.Button(root, text="Close", command=root.quit)
button.pack()
# Run the application
root.mainloop()
• Components of tkinter:
2.Weather Forecast:
Hourly, daily, or 5-day/3-hour forecasts.
5.Geocoding:
Convert city names or coordinates into geographic
information.
6.Weather Maps:
Visual maps with overlays for clouds, precipitation,
temperature, and wind.
• API Access:
2.Generate API Key: Obtain an API key after signing up. This
key authenticates our requests.
Conclusion
import tkinter as tk
from tkinter import messagebox
import requests
def get_weather():
city = city_entry.get()
if not city:
messagebox.showerror(“Error”, “Please
enter a city name”)
return
api_key = “f8c53154b1b91ca62c47c7eb1f2d8b5c” #
your OpenWeatherMap API key
try:
response = requests.get(url)
response.raise_for_status()
data = response.json()