· xcover-python ·
xcover-python is a Python API Client for XCover.
Installation
xcover-python is available on PyPI. To install the latest version run:
pip install xcover-python
or
poetry install xcover-python
Features
- Authentication
- Simple configuration using env variables
- (WIP) High-level API to perform partner operations on quotes and bookings
Configuration
Config object
The library provides XCoverConfig dataclass that can be used as shown:
from xcover import XCover, XCoverConfig
client = XCover(
XCoverConfig( # minimal config, check autocomplete for more options
base_url="https://api.xcover.com/xcover",
partner_code="--PARTNER_CODE--",
auth_api_key="--API_KEY--",
auth_api_secret="--API_SECRET--",
)
)
Env variables
Alternatively, it is possible to use env variables.
The full list of configuration options:
| Environment Variable | Config Property | Description | Default Value |
|---|---|---|---|
XC_BASE_URL |
XCoverConfig.base_url |
XCover base URL (e.g. https://api.xcover.com/api/v2/) |
- |
XC_PARTNER_CODE |
XCoverConfig.partner_code |
Partner code (e.g. LLODT) |
- |
XC_HTTP_TIMEOUT |
XCoverConfig.http_timeout |
HTTP timeout in seconds | 10 |
XC_AUTH_API_KEY |
XCoverConfig.auth_api_key |
API key to use | - |
XC_AUTH_API_SECRET |
XCoverConfig.auth_api_secret |
API secret to use | - |
XC_AUTH_ALGORITHM |
XCoverConfig.auth_algorithm |
HMAC encoding algorithm to use | hmac-sha512 |
XC_AUTH_HEADERS |
XCoverConfig.auth_headers |
Headers to sign | (request-target) date |
XC_RETRY_TOTAL |
XCoverConfig.retry_total |
Total number of retries | 5 |
XC_RETRY_BACKOFF_FACTOR |
XCoverConfig.retry_backoff_factor |
Backoff factor for retries timeout | 2 |
Usage example
Using low-level call method
import requests
from xcover.xcover import XCover
# Env variables are used
client = XCover()
# Prepare payload
payload = {
"request": [
{
"policy_type": "event_ticket_protection",
"policy_type_version": 1,
"policy_start_date": "2021-12-01T17:59:00.831+00:00",
"event_datetime": "2021-12-25T21:00:00+00:00",
"event_name": "Ariana Grande",
"event_location": "The O2",
"number_of_tickets": 2,
"tickets": [
{"price": 100},
],
"resale_ticket": False,
"event_country": "GB",
}
],
"currency": "GBP",
"customer_country": "GB",
"customer_region": "London",
"customer_language": "en",
}
# Calling XCover API
response: requests.Response = client.call(
method="POST",
url="partners/LLODT/quotes/",
payload=payload,
)
quote = response.json()
print(quote)
Retries
This client will automatically retry certain operations when it is considered safe to do this. The retry number and intervals could be controlled via XC_RETRY_TOTAL and XC_RETRY_BACKOFF_FACTOR environment variables ot the same config options.
Auto retry logic can be enabled/disabled per operation. However, further fine-tuning is possible via extending XCover class if required.
Metadata
Release files for xcover-python 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xcover_python-0.1.2.tar.gz | 5.8 kB | Without provenance | Details for xcover_python-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xcover_python-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for xcover_python-0.1.2-py3-none-any.whl |
Total release size: 13.1 kB
Release files / xcover_python-0.1.2.tar.gz
| Download URL | xcover_python-0.1.2.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6ebb891ba1c427a843c8a2d576253cad6e9c84ee76a81a0728a76b78084ed25
|
|
BLAKE2b-256 checksum How to use checksums |
5cc5adf3dab39066dd838b5959b47d430db6e50d5cfabc994d86e367276359bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / xcover_python-0.1.2-py3-none-any.whl
| Download URL | xcover_python-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae7c80cbacbfa55b94c64e8a65424ccebbba00b617634a10184059d5626f6b46
|
|
BLAKE2b-256 checksum How to use checksums |
4b952c9ea09e971c81a530f2de22e8c031499f39275569f0b27619fe9cf21994
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for xcover-python 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.