Task 6: Learn APIs and FastAPI
Issue Summary
Learn the basics of web APIs by working with a public API and building a simple API application using FastAPI. The task includes understanding API requests, responses, usage limits, and creating custom endpoints for handling simple data operations.
Problem Statement
Modern applications rely heavily on APIs for communication and data exchange. Beginners often lack practical experience in:
- Using public APIs
- Understanding API requests and responses
- Creating backend APIs
- Handling data through endpoints There is a need for a beginner-friendly task that introduces API concepts and backend development using FastAPI.
Proposed Solution
Develop small API-based applications to understand API usage and backend development. The task includes:
- Using a public API such as the OpenWeather API to fetch weather data for a city.
- Learning API concepts such as:
- GET requests
- POST requests
- JSON responses
- API rate limits and usage
- Creating a simple API using FastAPI.
Features to Implement
- Create a greeting API:
@app.get("/greet/{name}")
def greet(name: str):
return {"greeting": f"Hello, {name}!"}
- Build additional endpoints:
-
GET /villages- Returns a list of village names
-
POST /add-village- Adds a new village to an in-memory list
- Test APIs using:
- Browser
- Postman
- FastAPI Swagger UI
Expected Outcome
By completing this task, users will:
- Understand how APIs work
- Learn how to consume public APIs
- Build and test APIs using FastAPI
- Gain basic backend development knowledge
- Understand request-response architecture
Technologies Suggested
- Python
- FastAPI
- OpenWeather API
- Postman
- Uvicorn
Acceptance Criteria
- Public API integration works successfully
- Weather data can be fetched for a city
- Greeting API endpoint functions correctly
- Village list API endpoints work as expected
- API responses return proper JSON format
- APIs are tested successfully using Swagger UI or Postman
- Code is clean and properly documented
Edited by Vemuri priya