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 allure_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 allure_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 allure_api_client import BearerToken

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

# Use the auth with APIClient or AsyncAPIClient

Checking Status Code

from allure_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-1.2.4.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

allure_api_client-1.2.4-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: allure_api_client-1.2.4.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.0 Darwin/23.3.0

File hashes

Hashes for allure_api_client-1.2.4.tar.gz
Algorithm Hash digest
SHA256 59a1ab17214cef8ac788998a5052ee3fb64ecaea2890a22df3a048fa1b49f991
MD5 1e0f117bbd9a4e064eb7462240e64aad
BLAKE2b-256 3fc9464ed19e0fc7be08f0f57769263b4e0ebe123d4d794a7272bbdcf2313c26

See more details on using hashes here.

File details

Details for the file allure_api_client-1.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for allure_api_client-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f690bac675629bf0d7854227fd1cccb9e2496e578b4e24bd6116a7b1415d9dcb
MD5 d654c201690050dadb89d56dbff2d91d
BLAKE2b-256 f78a6c5d95de62bc98d231a922ff12fe75c88323bb23e2ebe53480d1cdaae2d9

See more details on using hashes here.

Supported by

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