A personal REST API automation framework built with Python, Requests and PyTest.
This project demonstrates practical API test automation covering GET, POST, PUT and DELETE operations, response validation, negative testing and response-time validation.
The framework uses a reusable API client, PyTest fixtures, centralized API configuration and automated HTML test reporting.
The purpose of this project is to demonstrate practical skills in:
- Python-based API automation
- REST API testing
- Requests library
- PyTest test execution
- Reusable API client design
- PyTest fixtures
- Centralized API configuration
- Response status-code validation
- JSON response validation
- Negative API testing
- Response-time validation
- Automated HTML test reporting
This is a personal portfolio project and contains no employer, client or confidential code.
| Technology | Purpose |
|---|---|
| Python | Programming language |
| Requests | HTTP/API requests |
| PyTest | Test framework |
| JSON | API request/response data handling |
| pytest-html | HTML test reporting |
| Git/GitHub | Version control and project hosting |
The framework currently contains 10 automated test cases.
| # | Test Scenario | Expected Result |
|---|---|---|
| 1 | Verify GET request returns successful response | HTTP 200 status code is returned |
| 2 | Verify response JSON structure | Expected JSON fields are present |
| 3 | Verify response contains expected data | Expected resource data is returned |
| 4 | Verify GET response time is acceptable | Response is received within the defined threshold |
| 5 | Verify POST request creates a resource | HTTP 201 status code is returned |
| 6 | Verify created resource data | Created resource contains expected data |
| 7 | Verify PUT request updates a resource | HTTP 200 status code is returned |
| 8 | Verify updated resource data | Updated resource contains expected data |
| 9 | Verify DELETE request removes a resource | HTTP 200 status code is returned |
| 10 | Verify invalid endpoint returns 404 | HTTP 404 status code is returned |
APIPRO/
│
├── api/
│ ├── __init__.py
│ └── api_client.py
│
├── reports/
│ └── report.html
│
├── tests/
│ ├── __init__.py
│ ├── test_get.py
│ ├── test_post.py
│ ├── test_put.py
│ ├── test_delete.py
│ └── test_negative.py
│
├── utils/
│ ├── __init__.py
│ └── config.py
│
├── .gitignore
├── conftest.py
├── pytest.ini
├── README.md
└── requirements.txt
api/
Contains the reusable APIClient class responsible for sending GET, POST, PUT and DELETE requests using the Requests library.
tests/
Contains PyTest test cases for API functional, validation, negative and response-time testing.
utils/
Contains centralized API configuration such as the base URL and API endpoints.
reports/
Contains the generated HTML test execution report.
conftest.py
Contains the shared PyTest fixture used to provide the reusable API client to test cases.
pytest.ini
Contains PyTest configuration, test discovery settings and HTML reporting options.
requirements.txt
Contains the Python dependencies required to run the project.
.gitignore
Defines files and folders that should not be committed to the Git repository, such as the virtual environment, Python cache and PyTest cache.
The framework uses a reusable APIClient class to centralize HTTP request operations.
Test Case
│
▼
PyTest Fixture
│
▼
APIClient
│
├── GET
├── POST
├── PUT
└── DELETE
│
▼
REST API
│
▼
API Response
The API client uses the Python Requests library to send HTTP requests and return API responses to the test cases.
This separation keeps test cases clean and makes the request logic reusable across the framework.
git clone https://github.com/nikhilshendgetech-sudo/APIPro.gitcd APIPropython -m venv .venvWindows:
.venv\Scripts\activatemacOS / Linux:
source .venv/bin/activatepip install -r requirements.txtRun all automated tests using:
pytestPyTest automatically discovers the test files inside the tests/ directory.
The project is configured through pytest.ini to:
- Discover tests from the
tests/directory - Run tests in verbose mode
- Generate an HTML test report
- Generate a self-contained HTML report
The project uses the publicly available JSONPlaceholder REST API for API automation practice.
API:
https://jsonplaceholder.typicode.com/
JSONPlaceholder is a public fake REST API designed for testing and prototyping.
The framework currently uses the following endpoints:
GET /posts/1
POST /posts
PUT /posts/1
DELETE /posts/1
An invalid endpoint is also used for negative testing:
GET /invalid-endpoint
Expected response:
404 Not Found
The project uses pytest-html to generate an HTML execution report.
The report provides:
- Test execution summary
- Passed and failed test results
- Test duration
- Environment information
- Individual test details
- Test execution results
The generated report is available at:
reports/report.html
The report is automatically generated when running:
pytestThe framework follows a reusable API client architecture.
Test Case
│
▼
PyTest Fixture
│
▼
APIClient
│
▼
Requests Library
│
▼
JSONPlaceholder API
│
▼
Response
│
▼
Assertions
The API request logic is maintained inside the api/ directory, configuration is maintained inside the utils/ directory, and test scenarios are maintained separately inside the tests/ directory.
This separation improves code reusability, readability and maintainability.
PyTest
│
▼
pytest.ini
│
▼
Discover Tests
│
▼
conftest.py
│
▼
Create APIClient Fixture
│
▼
Execute Test Cases
│
├── GET Tests
│ ├── Status Code
│ ├── JSON Structure
│ ├── Expected Data
│ └── Response Time
│
├── POST Tests
│ ├── Resource Creation
│ └── Created Data
│
├── PUT Tests
│ ├── Resource Update
│ └── Updated Data
│
├── DELETE Test
│ └── Resource Removal
│
└── Negative Test
└── Invalid Endpoint
│
▼
Test Results
│
▼
HTML Report
The current framework execution contains 10 automated tests.
10 passed
All implemented test scenarios are currently passing successfully.
API configuration is centralized in:
utils/config.py
The configuration currently contains:
BASE_URL = "https://jsonplaceholder.typicode.com"
POSTS_ENDPOINT = f"{BASE_URL}/posts"
POST_ENDPOINT = f"{BASE_URL}/posts/1"Centralizing the API URL and endpoints avoids unnecessary duplication across test files and makes the framework easier to maintain.
The framework uses a reusable PyTest fixture defined in:
conftest.py
The fixture provides an APIClient instance to the test cases.
@pytest.fixture
def api_client():
return APIClient()This avoids creating the API client manually inside every test case and promotes reusable test setup.
- Request and response logging
- Authentication support
- Environment-based configuration
- Test data management
- Additional API validations
- Custom API headers
- Schema validation
- Parameterized API tests
- CI/CD integration
- API performance testing
- Advanced reporting
This is a personal API automation demonstration project created to showcase Python and REST API automation capabilities.
The project uses a publicly available practice API and contains no employer, client or confidential information.