Skip to main content

An API client for simplifying API testing with Python + PyTest

Project description

🔥 berAPI 🔥

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

Project Link

Features

  • Builtin curl API in the pytest-html report
  • Easy to import the API logs into Postman/curl
  • Multiple common assertions to a single request

✨ Features

  • 🔥 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

Report

Installation

pip3 install berapi

How to use

Create 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)
     )

Configuration

env variable used in berapi

export MAX_RESPONSE_TIME=5
export MAX_TIMEOUT=3

To have robust response log make sure you enable settings in pytest.ini

[pytest]
log_cli_level = INFO

Install Development

pip install poetry
poetry install --with test

Run Test

poetry run pytest tests

Building Lib

poetry build
poetry publish

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

berapi-0.1.7.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

berapi-0.1.7-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file berapi-0.1.7.tar.gz.

File metadata

  • Download URL: berapi-0.1.7.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for berapi-0.1.7.tar.gz
Algorithm Hash digest
SHA256 26a087f0f1d28a40680c11a33be0c071bfe807650c83409e4e6479ef5e1ab7f3
MD5 c4973d94dc75fd62d7ae7c391061c59c
BLAKE2b-256 0223edab220bca0c61618e28ab78cf529847590d8ba6fea0612ad8411d827398

See more details on using hashes here.

File details

Details for the file berapi-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: berapi-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for berapi-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 5ab9b969cdf727309384e2e963b83907a56687dd8d85e1b2e3d4b6dd873f5296
MD5 aa585e79324d74e50157a2b0b5d8dbc0
BLAKE2b-256 c0068048994cb626ab1082a1333d9364ba75572e2c23e52f6f98479d6ba43e82

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