Skip to main content

API Client for Python ^3.10 and Pytest projects. It includes the Allure request/response hooks and the status code checking inside the main method. Request hook generates cURL, Response hook represents the useful information.

Project description

allure-api-client

The allure-api-client library is a Python package designed to facilitate API testing and reporting in Allure. Built on top of the httpx library, it provides both synchronous and asynchronous clients for making HTTP requests, complete with automatic request and response logging for Allure reports. The library also includes utilities for bearer token authentication and status code verification.

Features

  • Synchronous and Asynchronous API Clients
  • Automatic logging of requests and responses in Allure reports
  • Bearer Token Authentication
  • Status Code Verification

Installation

To install allure-api-client, you will need Python installed on your system. You can install the library using pip:

pip install allure-api-client

Usage

Synchronous API Client

from api_client import APIClient

# Initialize the client
client = APIClient(
    base_url="https://api.example.com",
    auth=BearerToken("YOUR_ACCESS_TOKEN"),  # Optional
    verify=False  # Optional
)

# Send a request
response = client.send_request(
    method="GET",
    path="/endpoint"
)

Asynchronous API Client

from api_client import AsyncAPIClient

# Initialize the client
async with AsyncAPIClient(
        base_url="https://api.example.com",
        auth=BearerToken("YOUR_ACCESS_TOKEN"),  # Optional
        verify=False  # Optional
) as client:
    # Send a request
    response = await client.send_request(
        method="GET",
        path="/endpoint"
    )

Bearer Token Authentication

from api_client import BearerToken

# Initialize the bearer token
auth = BearerToken("YOUR_ACCESS_TOKEN")

# Use the auth with APIClient or AsyncAPIClient

Checking Status Code

from api_client import check_status_code

# After receiving a response
check_status_code(response, 200)  # Verifies that the status code is 200

Contributing

Contributions to allure-api-client are welcome! Please follow the standard procedures to submit issues, pull requests, etc.

License

allure-api-client is released under the MIT License.

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

allure_api_client-25.297.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

allure_api_client-25.297-py2.py3-none-any.whl (9.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file allure_api_client-25.297.tar.gz.

File metadata

  • Download URL: allure_api_client-25.297.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Linux/6.11.0-1018-azure

File hashes

Hashes for allure_api_client-25.297.tar.gz
Algorithm Hash digest
SHA256 6253fe75f35e7a9e482a3b7f0ad1fa5fd6927bcc51183a3a745e409e37c80be2
MD5 68ba3d628c46192b08539a194b3c240a
BLAKE2b-256 9282a4b16a045b99fc1539157223847e9ee29a9d32cf00ac1c9d8099f85552fb

See more details on using hashes here.

File details

Details for the file allure_api_client-25.297-py2.py3-none-any.whl.

File metadata

  • Download URL: allure_api_client-25.297-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Linux/6.11.0-1018-azure

File hashes

Hashes for allure_api_client-25.297-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 21e3647c0aa3011da556a8c39c8f73e8e2befebc66d71731cbd498ea7f70e48d
MD5 86a0dac5487b3a7316804e0bea079527
BLAKE2b-256 4f9daebe8406cd99802e86e8e4a2b3b5132c863d431bcc96a300fb54fc290b94

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