hatang
The official Python SDK for Ha Tang: support CRM, plans and purchases on the customer's profile, the AI assistant's knowledge, email, VietQR payments and webhooks.
pip install hatang
Python 3.9+. Sync (Hatang) and asyncio (AsyncHatang) clients, typed request bodies.
Quick start
from hatang import Hatang
hatang = Hatang() # reads HATANG_API_KEY; or Hatang("ht_…")
# What a customer pays for, from your backend (web sales included).
hatang.chat.subscriptions.upsert("web", "sub_123", {
"status": "active",
"sku": "PRO-1M", # finds the product in your catalog
"external_user_id": "user-42", # the id you pass to identify() in the chat
"current_period_end": "2026-12-01T00:00:00Z",
"amount": 99000, "currency": "VND",
})
hatang.chat.purchases.upsert("web", "order_981", {
"store_product_id": "credits.300", "sku": "XU-300", "kind": "consumable",
"external_user_id": "user-42", "amount": 29000, "currency": "VND",
})
asyncio (FastAPI, aiohttp…):
from hatang import AsyncHatang
async with AsyncHatang() as hatang:
hits = await hatang.knowledge.search("hoàn tiền", limit=3)
Every method returns the API's JSON as a dict. A call that does not succeed raises HatangError with status_code
(0 when Ha Tang was not reached), name (validation_error, not_found…), message, and retryable (unreachable,
429 or 5xx).
What is in it
| Namespace | Methods |
|---|---|
chat.subscriptions |
upsert, list, for_customer, purchase_token |
chat.purchases |
upsert, list, for_customer |
chat.customers |
list, get, update, conversations, export_csv |
chat.conversations |
list, get, update, messages, send, send_products |
chat.products |
list, search, get, create, update, remove |
chat.orders |
list, get, create, update, payment_link |
knowledge |
upsert, batch, sync, get, list, remove, search |
emails, batch |
send, get, list, update, cancel; batch.send |
payments |
create, get, list, cancel |
events |
send |
Helpers
from hatang import identity_hash, purchase_token, construct_webhook_event, construct_ipn_event
# Signed chat identity: send this as `hash` with userId to identify() in the widget or the app SDKs.
identity_hash("user-42", IDENTITY_SECRET)
# StoreKit appAccountToken / Google Play obfuscatedAccountId for one of your users.
purchase_token("site_…", "user-42")
# Webhooks (whsec_… secret) and payment IPN calls: pass the raw body, before JSON parsing.
event = construct_webhook_event(request.body, request.headers, WEBHOOK_SECRET)
ipn = construct_ipn_event(request.body, request.headers, SECRET_KEY)
Both raise HatangSignatureError when the signature does not match; verify_webhook / verify_ipn return a bool.
Configuration
| Argument | Environment | Default |
|---|---|---|
api_key |
HATANG_API_KEY |
required |
base_url |
HATANG_BASE_URL |
https://api.hatang.dev |
environment |
HATANG_ENVIRONMENT |
the key's own |
timeout |
30 s | |
http_client |
an httpx.Client / httpx.AsyncClient of your own (proxies, retries, tests) |
Docs: hatang.dev/docs · License: MIT
Metadata
Release files for hatang 0.1.0
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 |
|---|---|---|---|---|
| hatang-0.1.0.tar.gz | 15.0 kB | With provenance | Details for hatang-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hatang-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for hatang-0.1.0-py3-none-any.whl |
Total release size: 30.5 kB
Release files / hatang-0.1.0.tar.gz
| Download URL | hatang-0.1.0.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9dcbb952a2ef66e9ba7c7b5b3eea2e2086ec1d1da60aa2e5ce39d33a8f382143
|
|
BLAKE2b-256 checksum How to use checksums |
d8230ee1fe2a9531d90c0fca28afd37b6aebf995371585348a633b491c06f401
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logRelease files / hatang-0.1.0-py3-none-any.whl
| Download URL | hatang-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
054e370d7b704846381559bbea84ee66d763d7db01ae54f2c1929ea1b0d8f1f4
|
|
BLAKE2b-256 checksum How to use checksums |
e8b6dcd0a6fa7ae717b4610f90cdc51ca21e8362acd31215e9e3f28a2675ec32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logSecurity for hatang 0.1.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for hatang-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logA 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.