Skip to main content

A lightweight, developer-friendly Python library for API test automation

Project description

APItestGenie

APItestGenie is a lightweight, developer-friendly Python library designed to simplify API testing for automation engineers. Version 1.0 focuses on clarity, correctness, and essential functionality without unnecessary complexity.


Overview

APItestGenie provides:

  • Two ways to perform API requests: Client mode and Simple mode
  • Built-in JSON assertions
  • JSON path assertions for nested responses
  • Basic retry logic with retries, retry delay, and retry_on_status
  • A ResponseWrapper abstraction for consistent behavior across requests
  • GET, POST, PUT, PATCH, DELETE support
  • Timeout and headers support
  • A complete pytest suite
  • A modern Python packaging layout using the src structure

Version 1.0 intentionally avoids heavy features like logging frameworks, async support, or automation framework integrations.


Installation

Clone the repository:

git clone https://github.com/Akash402/apitestgenie.git
cd apitestgenie

Create and activate a virtual environment:

python3 -m venv venv
source venv/bin/activate

Install dependencies:

pip install httpx pytest

(Optional) Install the library locally in editable mode:

pip install -e .

Usage Examples

Client Mode

from apitestgenie.client import ApiClient

api = ApiClient("https://jsonplaceholder.typicode.com", timeout=10)

response = api.get("/posts/1", retries=2)
response.assert_status(200)
response.assert_json_value("id", 1)

POST example:

resp = api.post("/posts", json={"title": "foo"})
resp.assert_status(201)

PUT example:

resp = api.put("/posts/1", json={"id": 1, "title": "updated"})
resp.assert_status(200)

DELETE example:

resp = api.delete("/posts/1")
resp.assert_status(200)

Simple Mode

from apitestgenie.simple import get

response = get("https://jsonplaceholder.typicode.com/posts/1")
response.assert_status(200)
print(response.json())

POST example:

from apitestgenie.simple import post

resp = post("https://jsonplaceholder.typicode.com/posts", json={"hello": "world"})
resp.assert_status(201)

Retry and timeout example:

resp = get(
    "https://jsonplaceholder.typicode.com/posts/1",
    retries=3,
    retry_delay=1,
    retry_on_status=[500],
    timeout=5
)

JSON Assertions

resp.assert_status(200)
resp.assert_json_key("id")
resp.assert_json_value("id", 1)
resp.assert_json_path_exists("title")
resp.assert_json_path_value("id", 1)

Running Tests

pytest

Project Structure

apitestgenie/
│
├── src/
│   └── apitestgenie/
│       ├── client.py
│       ├── simple.py
│       ├── response_wrapper.py
│       └── __init__.py
│
├── tests/
├── playground.py
├── pytest.ini
├── README.md
└── SCOPE.md

Version 1.0 Scope Summary

Included:

  • CRUD operations
  • Basic retry logic
  • JSON and JSON path assertions
  • ResponseWrapper abstraction
  • Simple and client modes
  • Header and timeout support
  • Test suite
  • Clean structure

Excluded:

  • Advanced retry logic
  • Logging framework
  • Robot/Behave integrations
  • Async support
  • Schema validation
  • Plugin system

License

MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apitestgenie-1.0.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apitestgenie-1.0.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file apitestgenie-1.0.0.tar.gz.

File metadata

  • Download URL: apitestgenie-1.0.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for apitestgenie-1.0.0.tar.gz
Algorithm Hash digest
SHA256 decfbf06f4d1eb019b9a3fee5e980b9801e50dcb2b1d7e97fd6041288b850286
MD5 379fa230bbdfd188e1f715933dd86dc3
BLAKE2b-256 5584c2b2941a2fb847f5df40213fd03a10cb01acb07979c03a0265169c3a5a41

See more details on using hashes here.

File details

Details for the file apitestgenie-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: apitestgenie-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for apitestgenie-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27e82ae2ecc31dd7f5736eee1cca1b019e14871e86292fb6c563ee405e3b73a0
MD5 24fdf341d92ce0e6cfc8bb2ac383fb84
BLAKE2b-256 aacd304e1f5efb14f074993af91418c091244d1693265be20ed2d799ff48e345

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page