Skip to content

Joaoaalves/tiny-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tiny-py

Production-grade Python SDK for the Tiny ERP API v2. Fully typed, async-ready, and safe for FastAPI services and message queue workers.

PyPI version Python License: MIT


Features

  • Single entry point — all interaction through TinyClient or AsyncTinyClient
  • Typed contracts — every method accepts and returns Pydantic v2 models
  • Automatic rate limiting — token bucket per client instance, plan-aware (30 / 60 / 120 RPM)
  • Retry with exponential backoff — automatic on 429 / 5xx responses
  • Sync + AsyncTinyClient for workers, AsyncTinyClient for FastAPI
  • No global state — multiple tokens and plans can coexist in the same process

Installation

pip install tiny-py

Requires Python 3.11+.

Quick example

from tiny_py import TinyClient

client = TinyClient(token="your_token", plan="advanced")

# Stream all active products
for product in client.products.iter_search():
    print(product.sku, product.name, product.price)

# Fetch a single order
order = client.orders.get("970977594")
print(order.number, order.total)

Async (FastAPI)

from tiny_py import AsyncTinyClient

async with AsyncTinyClient(token="your_token", plan="advanced") as client:
    products = await client.products.search()
    order = await client.orders.get("970977594")

API coverage (v0.1.0)

Resource Methods
Products search, iter_search, get, get_stock, update_stock, update_price
Orders search, iter_search, get

See the roadmap for planned resources.

Error handling

from tiny_py.exceptions import TinyAPIError, TinyRateLimitError, TinyServerError, TinyTimeoutError

try:
    order = client.orders.get(order_id)
except TinyAPIError:
    # Business error — do not retry (send to DLQ)
    ...
except (TinyRateLimitError, TinyServerError, TinyTimeoutError):
    # Transient error — re-enqueue with backoff
    ...

License

MIT

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages