0% found this document useful (0 votes)
15 views2 pages

API Basics and Postman Guide

The document provides an overview of Backend API basics, explaining what an API is, its endpoints, and the structure of API URLs. It also covers how APIs are created using Spring Boot, the flow of data from controller to database, and how to make API calls using Postman and curl. Key HTTP methods such as GET, POST, PUT, and DELETE are also discussed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

API Basics and Postman Guide

The document provides an overview of Backend API basics, explaining what an API is, its endpoints, and the structure of API URLs. It also covers how APIs are created using Spring Boot, the flow of data from controller to database, and how to make API calls using Postman and curl. Key HTTP methods such as GET, POST, PUT, and DELETE are also discussed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Backend API Basics and Postman Guide

1. API kya hota hai?

API (Application Programming Interface) ek bridge hai frontend aur backend ke beech mein.
Ye frontend ko allow karta hai backend se data maangne ya bhejne ke liye.
Example: Jab app se user ka data chahiye hota hai, toh API call ki jaati hai.

2. API Endpoints kya hote hain?

API endpoint ek specific URL hota hai jahan pe backend ek kaam karta hai.
Example:
GET /api/users -> sabhi users ka data laata hai
GET /api/users/5 -> ID 5 ka user data laata hai
POST /api/users -> naya user create karta hai

3. API URL mein kya hota hai?

URL structure:
http://localhost:8080/api/users/5

- http://localhost:8080 -> server ka base URL


- /api/users -> endpoint path
- /5 -> specific resource (user with ID 5)

HTTP Methods:
- GET: Data lena
- POST: Naya data bhejna
- PUT: Data update karna
- DELETE: Data delete karna

4. Backend mein API kaise banti hai (Spring Boot Example)

@RestController
@RequestMapping("/api/users")
public class UserController {
@GetMapping("/{id}")
public User getUser(@PathVariable int id) {
return userService.getUserById(id);
}

@PostMapping("/")
public User createUser(@RequestBody User user) {
return userService.saveUser(user);
}
Backend API Basics and Postman Guide

5. Data kahaan se uthta hai aur kahaan jaata hai?

GET:
- Controller -> Service -> Repository -> Database

POST:
- Controller -> Service -> Repository -> Database

Controller: API handle karta hai


Service: Business logic likhte hain
Repository: DB se data uthata/daalta hai

6. Postman mein API call kaise karte hain?

Step-by-step:
1. Postman open karo
2. Method select karo (GET/POST/PUT/DELETE)
3. URL daalo: http://localhost:8080/api/users/1
4. Agar POST hai toh Body tab mein JSON data daalo:
{
"name": "John",
"email": "[email protected]"
}
5. 'Send' button dabao
6. Niche response aayega

7. Testing Example (curl)

GET request:
curl -X GET http://localhost:8080/api/users/1

POST request:
curl -X POST http://localhost:8080/api/users -H "Content-Type: application/json" -d "{\"name\":\"John\"}"

You might also like