API Testing Practice
Master API testing with hands-on examples. Learn to send requests, validate responses, and automate API test scenarios.
API Documentation
View complete OpenAPI 3.0 specification with interactive Swagger UI
Base URL:
https://practiceautomatedtesting.com/v1GET
/api/booksGet all books with optional pagination
Code Examples:
curl -X GET "https://practiceautomatedtesting.com/v1/api/books"
Response Example:
{
"success": true,
"data": [
{
"id": 1,
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"isbn": "978-0743273565",
"price": 12.99,
"inStock": true
},
{
"id": 2,
"title": "To Kill a Mockingbird",
"author": "Harper Lee",
"isbn": "978-0061120084",
"price": 14.99,
"inStock": true
},
{
"id": 3,
"title": "1984",
"author": "George Orwell",
"isbn": "978-0452284234",
"price": 13.99,
"inStock": false
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 3
}
}GET
/api/books/1Get a specific book by ID
Code Examples:
curl -X GET "https://practiceautomatedtesting.com/v1/api/books/1"
Response Example:
{
"success": true,
"data": {
"id": 1,
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"isbn": "978-0743273565",
"price": 12.99,
"inStock": true,
"description": "A novel set in the Jazz Age that tells the story of Jay Gatsby.",
"publishedDate": "1925-04-10",
"category": "Classic Literature"
}
}POST
/api/booksCreate a new book
Code Examples:
curl -X POST "https://practiceautomatedtesting.com/v1/api/books" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "New Book Title",
"author": "Author Name",
"isbn": "978-1234567890",
"price": 19.99,
"inStock": true,
"description": "Book description",
"category": "Fiction"
}'Request Body:
{
"title": "New Book Title",
"author": "Author Name",
"isbn": "978-1234567890",
"price": 19.99,
"inStock": true,
"description": "Book description",
"category": "Fiction"
}Response Example:
{
"success": true,
"message": "Book created successfully",
"data": {
"id": 4,
"title": "New Book Title",
"author": "Author Name",
"isbn": "978-1234567890",
"price": 19.99,
"inStock": true
}
}PUT
/api/books/1Update an existing book
Code Examples:
curl -X PUT "https://practiceautomatedtesting.com/v1/api/books/1" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Updated Title",
"price": 15.99,
"inStock": false
}'Request Body:
{
"title": "Updated Title",
"price": 15.99,
"inStock": false
}Response Example:
{
"success": true,
"message": "Book updated successfully",
"data": {
"id": 1,
"title": "Updated Title",
"author": "F. Scott Fitzgerald",
"price": 15.99,
"inStock": false
}
}DELETE
/api/books/1Delete a book
Code Examples:
curl -X DELETE "https://practiceautomatedtesting.com/v1/api/books/1" \ -H "Authorization: Bearer YOUR_TOKEN"
Response Example:
{
"success": true,
"message": "Book deleted successfully"
}POST
/api/auth/registerRegister a new user
Code Examples:
curl -X POST "https://practiceautomatedtesting.com/v1/api/auth/register" \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "SecurePass123!",
"firstName": "John",
"lastName": "Doe"
}'Request Body:
{
"email": "user@example.com",
"password": "SecurePass123!",
"firstName": "John",
"lastName": "Doe"
}Response Example:
{
"success": true,
"message": "User registered successfully",
"data": {
"id": 1,
"email": "user@example.com",
"firstName": "John",
"lastName": "Doe"
}
}POST
/api/auth/loginLogin and receive authentication token
Code Examples:
curl -X POST "https://practiceautomatedtesting.com/v1/api/auth/login" \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "SecurePass123!"
}'Request Body:
{
"email": "user@example.com",
"password": "SecurePass123!"
}Response Example:
{
"success": true,
"message": "Login successful",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 3600,
"user": {
"id": 1,
"email": "user@example.com",
"firstName": "John",
"lastName": "Doe"
}
}
}API Test Scenarios for Automation Practice
GET Requests:
- Test successful GET request for all books
- Verify response status code is 200
- Validate response contains array of books
- Check pagination data is present
- Test GET request for specific book by ID
- Verify book details are complete
POST/PUT/DELETE:
- Test POST request to create a new book
- Verify authentication header is required
- Test PUT request to update book details
- Verify updated values in response
- Test DELETE request removes book
- Validate error responses (404, 401, 400)
Authentication:
- Test user registration endpoint
- Verify login returns JWT token
- Test token expiration handling
- Verify protected endpoints require auth
- Test refresh token workflow
Response Validation:
- Validate JSON response structure
- Check data types of response fields
- Verify required fields are present
- Test response time is acceptable
- Validate success/error message format