Villa Market Backend SDK
Python SDK and CLI for the Villa Market backend: Cognito authentication, order building, validation, and card payment.
User Manual (hosted)
The manual covers installation, Cognito login/SignUp, order building, pre-payment validation, card payment, CLI commands, environment variables, and troubleshooting. It is rebuilt and deployed to S3 automatically when docs change on main.
Quick start
1. Install
pip install villa-market-backend-sdk
Python import: from villa_backend_sdk import VillaClient
2. Configure Cognito
cp .env.example .env
# Set VILLA_COGNITO_CLIENT_SECRET from Cognito → Show client secret
set -a && source .env && set +a
| Variable | Description |
|---|---|
VILLA_COGNITO_CLIENT_ID |
Cognito app client ID |
VILLA_COGNITO_USER_POOL_ID |
Cognito user pool ID |
VILLA_COGNITO_CLIENT_SECRET |
App client secret |
VILLA_COGNITO_REGION |
AWS region (default ap-southeast-1) |
3. Login and call APIs
from villa_backend_sdk import VillaClient, OrderBuilder
client = VillaClient.from_env()
client.login("user@example.com", "password") # attaches JWT to all requests
order = (
OrderBuilder()
.with_ids(order_id="order-1", owner_id="owner-1", basket_id="basket-1")
.with_branch("1000")
.add_product(cprcode=25281, quantity=1)
.with_payment_totals(grand_total=174.0)
.build()
)
result = client.pre_payment.validate(order, expected_grand_total=174.0)
print(result.valid)
Verify login:
python3 scripts/smoke_test_cognito_login.py
CLI
villa auth login --username user@example.com --password 'secret'
villa health
villa order validate-schema --file tests/fixtures/goodSample.json
villa validate pre-payment --file tests/fixtures/goodSample.json --expected-grand-total 500
See the manual for the full CLI reference.
Documentation
| Document | Contents |
|---|---|
| Manual (S3) | Complete usage guide |
| docs/MANUAL.md | Manual source (repo) |
| docs/DESIGN.md | Architecture and data flow |
| docs/TESTING.md | Test strategy |
| docs/COGNITO_TEST.md | Shared test account |
| docs/CI_CD.md | CI/CD and deployment |
Development
git clone https://github.com/villa-market/villa-backend-sdk-1.git
cd villa-backend-sdk-1
pip install -e ".[dev]"
set -a && source .env && set +a
pytest
| Suite | Command |
|---|---|
| Unit | pytest tests/unit -m unit |
| Integration (real Cognito JWT) | pytest tests/integration -m integration |
| Full | pytest (72 tests) |
Build and deploy the manual locally:
python3 scripts/build_manual_site.py
python3 scripts/deploy_manual_s3.py
Architecture
| Module | Responsibility |
|---|---|
villa_backend_sdk.auth |
Cognito login, SignUp, confirm |
villa_backend_sdk.orders |
Order builder, create/get/generate ID |
villa_backend_sdk.validation |
Schema + remote pricing validation |
villa_backend_sdk.payments |
Card token, card payment, verify |
villa_backend_sdk.cli |
villa command-line tool |
License
MIT
Metadata
Release files for villa-market-backend-sdk 0.2.1
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 | |
|---|---|---|---|---|
| villa_market_backend_sdk-0.2.1.tar.gz | 26.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| villa_market_backend_sdk-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.6 kB
Release files / villa_market_backend_sdk-0.2.1.tar.gz
| Download URL | villa_market_backend_sdk-0.2.1.tar.gz |
|---|---|
| Size | 26.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae6e0acc92820dea6707bdd3468bfd2f207bf3fe781c73c6dd7ec230f8547bcf
|
|
BLAKE2b-256 checksum How to use checksums |
178113a640f482b494928fb10f21670a6768741b6b6bc1557b43381437302190
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / villa_market_backend_sdk-0.2.1-py3-none-any.whl
| Download URL | villa_market_backend_sdk-0.2.1-py3-none-any.whl |
|---|---|
| Size | 34.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cfd19c8552763b52eb37c20c6a2d75341f965eb7973cf32eb6c42ad33198fa2c
|
|
BLAKE2b-256 checksum How to use checksums |
a38aa768941a167de524890a83e882f781e747efcdf64b4ca421e309c39d4c6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for villa-market-backend-sdk 0.2.1
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.