SDKs

CHRT provides official SDKs for TypeScript and Python to help you integrate with our API quickly and safely. Our SDKs are built with Fern, ensuring type-safety and up-to-date API coverage.

Available SDKs

TypeScript/JavaScript

npm shield

Install the SDK using npm:

$npm install @chrt/sdk

Basic usage example:

1import { ChrtClient } from "@chrt/sdk";
2
3const client = new ChrtClient({
4 environment: "YOUR_BASE_URL"
5});
6
7try {
8 await client.messages.postShipperToCourier({
9 user_handle: "user_handle",
10 ShipperToCourierCreate: 1,
11 schema_version: 1,
12 user_id: "user_id",
13 name: "name",
14 email_address: "email_address",
15 message: "message",
16 phone_number: "phone_number",
17 created_at: "2024-01-15T09:30:00Z",
18 viewed: true
19 });
20} catch (err) {
21 if (err instanceof ChrtError) {
22 console.error(`Error ${err.statusCode}: ${err.message}`);
23 console.error(err.body);
24 }
25}

Python

pypi

Install the SDK using pip:

$pip install chrt

Synchronous Client

1import datetime
2from chrt import Chrt
3
4client = Chrt(
5 base_url="https://yourhost.com/path/to/api"
6)
7
8try:
9 client.messages.post_shipper_to_courier(
10 user_handle="user_handle",
11 shipper_to_courier_create=1,
12 schema_version=1,
13 user_id="user_id",
14 name="name",
15 email_address="email_address",
16 message="message",
17 phone_number="phone_number",
18 created_at=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"),
19 viewed=True
20 )
21except ApiError as e:
22 print(f"Error {e.status_code}: {e.body}")

Async Client

The Python SDK also provides an async client for non-blocking API calls:

1import asyncio
2import datetime
3from chrt import AsyncChrt
4
5client = AsyncChrt(
6 base_url="https://yourhost.com/path/to/api"
7)
8
9async def main():
10 try:
11 await client.messages.post_shipper_to_courier(
12 user_handle="user_handle",
13 shipper_to_courier_create=1,
14 schema_version=1,
15 user_id="user_id",
16 name="name",
17 email_address="email_address",
18 message="message",
19 phone_number="phone_number",
20 created_at=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"),
21 viewed=True
22 )
23 except ApiError as e:
24 print(f"Error {e.status_code}: {e.body}")
25
26asyncio.run(main())

Advanced Features

Request Timeouts

Both SDKs support configurable request timeouts:

1// TypeScript: 30 second timeout
2const response = await client.messages.postShipperToCourier(data, {
3 timeoutInSeconds: 30
4});
1# Python: Configure timeout at client level
2client = Chrt(
3 base_url="https://yourhost.com/path/to/api",
4 timeout=20.0
5)
6
7# Or override for specific requests
8client.messages.post_shipper_to_courier(..., request_options={
9 "timeout_in_seconds": 1
10})

Automatic Retries

Our SDKs include automatic retries with exponential backoff for the following status codes:

  • 408 (Request Timeout)
  • 429 (Too Many Requests)
  • 5XX (Server Errors)

Configure maximum retries:

1// TypeScript
2const response = await client.messages.postShipperToCourier(data, {
3 maxRetries: 0 // Disable retries
4});
1# Python
2client.messages.post_shipper_to_courier(..., request_options={
3 "max_retries": 1
4})

Custom Configuration

TypeScript Runtime Support

The TypeScript SDK works in:

  • Node.js 18+
  • Vercel
  • Cloudflare Workers
  • Deno v1.25+
  • Bun 1.0+
  • React Native

Python Custom Client

Configure the Python SDK with custom HTTP client options:

1import httpx
2from chrt import Chrt
3
4client = Chrt(
5 base_url="https://yourhost.com/path/to/api",
6 httpx_client=httpx.Client(
7 proxies="http://my.test.proxy.example.com",
8 transport=httpx.HTTPTransport(local_address="0.0.0.0")
9 )
10)

For more information about our APIs and integrations, check out our API Reference or contact our Support team.