A hands-on collection of Python programs demonstrating how to consume REST APIs, work with real-world data, and build APIs using FastAPI — from beginner to practical level.
api-projects/
│
├── real-time-currency-converter.py # Live forex rates using ExchangeRate API
├── connect-api-using-python.py # Pokémon data via PokéAPI
├── making-api-call.py # Intro to GET requests with JSONPlaceholder
├── first-api.py # Core API concepts & combined examples
└── fastapi.py # Building REST APIs using FastAPI
File: real-time-currency-converter.py
Converts currency amounts in real time using live exchange rates from the ExchangeRate API.
- Fetches live rates via HTTP GET request
- Supports USD, EUR, GBP, JPY, INR
- Calculates cross-currency conversion using rate ratio formula
python real-time-currency-converter.py
# Enter amount: 1000
# From: INR → To: USD
# Output: 1000 INR = 11.97 USDAPI Used: https://api.exchangerate-api.com/v4/latest/USD
File: connect-api-using-python.py
Fetches real-time Pokémon data (ID, height, weight, abilities) from the public PokéAPI.
- Makes a GET request to a dynamic URL with user input
- Handles HTTP status codes (200 vs errors)
- Parses nested JSON response
python connect-api-using-python.py
# Enter Pokemon name: pikachu
# Name: Pikachu | ID: 25 | Height: 4 | Weight: 60
# Abilities: static, lightning-rodAPI Used: https://pokeapi.co/api/v2/pokemon/{name}
File: making-api-call.py
Introductory example showing the complete anatomy of an API call — request, response, status check, and JSON parsing.
- Uses JSONPlaceholder (free fake REST API for testing)
- Demonstrates
response.status_codeandresponse.json() - Clean error handling with else block
API Used: https://jsonplaceholder.typicode.com/posts/1
File: first-api.py
A consolidated file containing all API practice examples written during the learning journey — currency converter, Pokémon fetcher, API call basics, and FastAPI endpoints in one place.
File: fastapi.py
Demonstrates how to build a REST API from scratch using FastAPI — the modern, high-performance Python framework.
# Endpoint 1: Hello World
GET / → {"Hello": "World"}
# Endpoint 2: Items List
GET /items/ → [{"name": "Ramesh"}, {"name": "Suresh"}]Run the server:
uvicorn fastapi:app --reloadThen open: http://127.0.0.1:8000/docs for the interactive Swagger UI.
| Technology | Purpose |
|---|---|
| Python 3.10+ | Core programming language |
requests |
Consuming external REST APIs (HTTP GET) |
FastAPI |
Building REST API endpoints |
uvicorn |
ASGI server to run FastAPI |
| ExchangeRate API | Live forex/currency rates |
| PokéAPI | Pokémon data (public, no auth needed) |
| JSONPlaceholder | Fake REST API for testing & learning |
- Python 3.10 or above
- pip
git clone https://github.com/rameshgehlot76/api-projects.git
cd api-projectspip install requests fastapi uvicornpython real-time-currency-converter.py
python connect-api-using-python.py
python making-api-call.pyuvicorn fastapi:app --reload- What an API is and how HTTP requests (GET) work
- Parsing and navigating JSON responses in Python
- Handling API errors using
status_codechecks - Making dynamic API calls with user input
- Building REST API endpoints using FastAPI
- Understanding API endpoints, routes, and responses
- How
requests.get(),response.json(), and status codes work together
- Add POST request examples
- Add API key authentication examples
- Build a weather app using OpenWeatherMap API
- Add FastAPI with Pydantic models and request body
- Deploy a FastAPI project on Render or Railway
Ramesh Gehlot B.Tech Computer Science | AI & ML Enthusiast
⭐ If this helped you understand APIs better, consider giving this repo a star!