Complete API Descriptive Sheet
1. What is an API?
API (Application Programming Interface) is a set of rules that allows two applications to talk to each other. It
acts as a messenger between client and server.
2. REST API vs RESTful API
REST API: Any API that follows REST principles.
RESTful API: An API that strictly adheres to REST design constraints like statelessness, uniform interface,
etc.
3. HTTP Methods
- GET: Retrieve data
- POST: Send new data
- PUT: Replace existing data
- PATCH: Update part of existing data
- DELETE: Remove data
4. Status Codes
- 200: OK (Success)
- 201: Created
- 400: Bad Request
- 401: Unauthorized
- 404: Not Found
- 500: Server Error
5. Headers & Body
Headers: Metadata like Content-Type, Authorization.
Body: Data sent (mainly in POST/PUT requests) usually in JSON format.
Complete API Descriptive Sheet
6. JSON & Query Params
JSON is the standard format for sending/receiving data.
Query params are added to URLs like ?city=delhi&units=metric
7. Tools Used
- Postman: GUI tool to test APIs
- fetch(): JavaScript method to call APIs
- async/await: Modern async handling in JS
8. Public APIs & Keys
APIs like OpenWeatherMap, NewsAPI, etc., often require API keys. Keys should be kept secret in production.
9. API Errors & Debugging
- Always check status codes
- Use console.log and catch blocks
- Validate input before making requests
10. Best Practices
- Always handle errors
- Use try/catch with async
- Validate user input
- Keep keys secure
- Test APIs with Postman before coding