Skip to main content

hatang

PyPI

The official Python SDK for Ha Tang: customer support CRM and live chat, 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)

License: MIT

About Ha Tang

Ha Tang (Hạ Tầng) is a customer support platform for businesses in Vietnam: one inbox for your website, mobile app, Zalo, Messenger, Instagram, TikTok Shop, WhatsApp and email, with an AI assistant, plus a transactional email API, VietQR payments and e-invoices.

Metadata

Release files for hatang 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hatang 0.1.1
File Size Uploaded Provenance Actions
hatang-0.1.1.tar.gz 15.6 kB With provenance Details for hatang-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hatang 0.1.1
File Interpreter ABI Platform Actions
hatang-0.1.1-py3-none-any.whl Python 3 none any Details for hatang-0.1.1-py3-none-any.whl

Total release size: 31.5 kB

Release files / hatang-0.1.1.tar.gz

Download URL hatang-0.1.1.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
760acdf09bad1dd3ee3d7bae7abf26dea9f9707bceb06d0d33791ffd29f702e8
BLAKE2b-256 checksum
How to use checksums
c15ec0addaf532e97db0d4b2145d7d131be6d6fca2f5be337aba10654dd765a6
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 Nov 3, 2026.

Transparency log

Release files / hatang-0.1.1-py3-none-any.whl

Download URL hatang-0.1.1-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
790c869a780e58c68c1b7269fdbb4ade219750fd597d6d4ef4fa708716f0a400
BLAKE2b-256 checksum
How to use checksums
075743cc1a8d77edc7e3b845064da99c97259f4892a310b9f22c09486eb5258c
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 Nov 3, 2026.

Transparency log

Security for hatang 0.1.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for hatang-0.1.1.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 Nov 3, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page