Skip to main content

Python SDK for the Lynara ERP platform — Sales, Purchases, Banking, Inventory, Catalog, CRM, HR

Project description

Lynara Python SDK

Python SDK for the Lynara ERP platform.

Installation

pip install lynara-erp

With httpx (optional, for better performance):

pip install lynara-erp[httpx]

Quick Start

from lynara import Lynara

# --- Production ---
client = Lynara(
    url="https://api.lynara.ai",
    api_key="lnr_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    company_id="your-company-uuid",
)

# --- Test / Sandbox ---
test_client = Lynara(
    url="https://api.lynara.ai",
    api_key="lnr_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    company_id="your-company-uuid",
)

# List customers
customers = client.catalog.customers.list(limit=50)
print(f"Found {customers.total_count} customers")

for customer in customers:
    print(customer["name"], customer["contact_email"])

# Search
results = client.rh.employees.list(search="Ali")
print(f"Found {results.total_count} employees matching 'Ali'")

# Count
total_invoices = client.sales.invoices.count()
print(f"Total invoices: {total_invoices}")

# Create a customer
customer = client.catalog.customers.create({
    "name": "Acme Corp",
    "contact_email": "contact@acme.com",
    "customer_type": "B2B",
})
print(f"Created customer: {customer['customer_id']}")

# Update
client.catalog.customers.update(customer["customer_id"], {
    "priority": "high",
    "lifecycle_stage": "loyal",
})

# Delete
client.catalog.customers.delete(customer["customer_id"])

# Iterate through all products (auto-pagination)
for product in client.catalog.products.iterate():
    print(product["name"], product["price"])

# Bulk create
result = client.catalog.products.bulk_create([
    {"name": "Widget A", "price": 29.99, "currency": "EUR"},
    {"name": "Widget B", "price": 49.99, "currency": "EUR"},
])
print(f"Created {result.created_count}/{result.total_submitted}")

# Export to CSV
csv_data = client.catalog.customers.export(format="csv")
with open("customers.csv", "w") as f:
    f.write(csv_data)

# Close when done
client.close()

Context Manager

with Lynara(url="https://api.lynara.ai", api_key="lnr_live_xxx", company_id="xxx") as client:
    invoices = client.sales.invoices.list(status="posted")
    total = client.sales.invoices.count()
    print(f"{total} invoices")

Modules

Module Accessor Resources
Sales client.sales quotes, quote_lines, orders, order_lines, invoices, invoice_lines, delivery_notes, delivery_note_lines, exit_vouchers, exit_voucher_lines, credit_notes, credit_note_lines, allocations, receipts
Purchases client.purchases invoices, invoice_lines, payments, allocations, quotes, quote_lines
Banking client.banking statements, transactions, reconciliations
Inventory client.inventory storage_units, product_settings, stock_levels, lots, movements, serial_numbers, stock_counts
Catalog client.catalog customers, suppliers, products, product_categories, product_subcategories, price_lists
CRM client.crm leads, opportunities, activities, pipeline_stages
HR client.rh employees, contracts, contract_history, addresses, bank_accounts, departments, employee_roles, employee_dependents, employee_history, employee_documents, salary_history, bonuses, bonuses_history, indemnities, indemnities_history, benefits_in_kind, benefits_in_kind_history, employee_leaves, leave_requests, leave_balances, absences, time_entries, expense_reports, expense_lines, trainings, employee_trainings, training_notes, skills, employee_education, employee_certifications, employee_work_experience

Resource Methods

Every resource supports:

Method Description
.list(limit, offset, order_by, order, search, **filters) Paginated list
.get(id) Get by ID
.create(data) Create record
.update(id, data) Update record
.delete(id) Delete record
.bulk_create(items) Create up to 500 records
.export(format, limit) Export as JSON or CSV
.count() Total count
.iterate(batch_size, **filters) Auto-paginated generator

Pagination

# Manual pagination
page1 = client.sales.invoices.list(limit=50, offset=0)
print(page1.total_count, page1.page, page1.total_pages, page1.has_more)

page2 = client.sales.invoices.list(limit=50, offset=50)

# Auto-pagination (recommended for large datasets)
for invoice in client.sales.invoices.iterate(batch_size=100):
    process(invoice)

Search & Count

# Search across searchable fields (name, email, reference, etc.)
results = client.rh.employees.list(search="Ali")
results = client.catalog.customers.list(search="Acme")

# Count records
total_customers = client.catalog.customers.count()
total_leads = client.crm.leads.count()
print(f"{total_customers} customers, {total_leads} leads")

# Ordering
recent = client.crm.leads.list(order_by="created_at", order="desc")

Error Handling

from lynara import (
    Lynara,
    LynaraError,
    AuthenticationError,
    LynaraPermissionError,
    NotFoundError,
    RateLimitError,
    ValidationError,
)

try:
    client.sales.invoices.get("invalid-id")
except NotFoundError:
    print("Invoice not found")
except AuthenticationError:
    print("Invalid API key")
except LynaraPermissionError:
    print("Module not allowed for this key")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after}s")
except ValidationError:
    print("Invalid data")
except LynaraError as e:
    print(f"API error: {e.message} (status {e.status_code})")

API Keys

Generate API keys from Lynara > Settings > API Keys.

  • lnr_live_xxx — Production key (real data)
  • lnr_test_xxx — Test key (sandbox)

Each key has configurable:

  • Permissions: read, write, bulk, delete, export
  • Modules: restrict to specific modules (sales, crm, rh, etc.)
  • Rate limit: 30 to 1000 requests per minute

Full API Reference

See lynara.ai/api for complete column definitions of all tables.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lynara_erp-1.0.1.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lynara_erp-1.0.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file lynara_erp-1.0.1.tar.gz.

File metadata

  • Download URL: lynara_erp-1.0.1.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for lynara_erp-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ecb5a007f28e8bd1898033c3650239102537da81f387e6e1aa370bde3c6ec5fe
MD5 695f1fbb6fed497777d80f2f91de984a
BLAKE2b-256 f7d0b87235cf115d510bb15219fec9fecc2bba4ab4983c831e28d0a9d73bac29

See more details on using hashes here.

File details

Details for the file lynara_erp-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: lynara_erp-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for lynara_erp-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5e8516609bfc7f8e4c68ce5946b4ee31dff75d6de5c4a592d8681ce05b3c862b
MD5 524d5c297e1158b75078cc281b86ce90
BLAKE2b-256 c6835690942c846e634935e251aa86b8e88e0698615c6523a048b5b41150f3fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page