berapi is a lightweight API client that simplifies API testing using Python and Pytest It supports chained assertions, curl logging, and quick response validation for fast and efficient API testing
- Builtin curl API in the
pytest-htmlreport - Easy to import the API logs into Postman/curl
- Multiple common assertions to a single request
- 🔥 Simple Fluent API — chainable syntax like .get().assert_2xx().parse_json()
- 📋 Auto Logging — automatically generate curl commands for debugging or Postman import
- 🛡️ Built-in Assertions — status code, response body, JSON key/value, and schema validation
- 🕐 Response Time Checking — ensure your APIs are fast and stable
- 📜 JSONPath Support (coming soon) — flexible access to nested JSON data
pip3 install berapiCreate an instance of berAPI class, and you can build API test request and assertion chain of the response
from berapi.apy import berAPI
def test_simple():
url = 'https://swapi.dev/api/people/1'
api = berAPI()
response = api.get(url).assert_2xx().parse_json()
assert response['name'] == 'Luke Skywalker'
def test_chaining():
(berAPI()
.get('https://swapi.dev/api/people/1')
.assert_2xx()
.assert_value('name', 'Luke Skywalker')
.assert_response_time_less_than(seconds=1)
)env variable used in berapi
export MAX_RESPONSE_TIME=5
export MAX_TIMEOUT=3To have robust response log make sure you enable settings in pytest.ini
[pytest]
log_cli_level = INFOpip install poetry
poetry install --with testpoetry run pytest testspoetry build
poetry publish