REST API · PYTHON 3

Python code examples

Three ready-to-adapt scripts that automate real tasks with the Wyzio REST API: late notices, invoices and contact imports.

Python 3

httpx

api-v1

Terminal

import httpx

BASE_URL = "[API base URL]"
client = httpx.Client(base_url=BASE_URL, headers={
    "User-Agent”: "Wyzio/1.0",
    "weal-token”: "<your token>",
    "target-organization-id”: "<organization id>",
    "Content-Type”: "application/json",
})

orgs = client.get("/api-v1/organization").json()

AUTHENTICATION

Before you start

01

Install the libraries

pip install httpx xlrd

02

Get your API token

From a contact with the Webservice role. How →

03

Note your organisation ID

Sent in the target-organization-id header.

The examples

01 - late_notice.py

Sending late notices by email

Finds overdue invoices, generates a PDF late notice for each client and emails it in the client's language: English, French, German or Italian. When the reminder level is exceeded or the client has no email, the notice goes to your litigation address instead.

/api-v1/late-notice/client 

/api-v1/sales-invoice

/api-v1/contact

/api-v1/generate-pdf

Also needs: an SMTP server and its credentials

View the code

Download .py

01 · late_notice.py

Sending late notices by email

Python 3 · 298 lines · httpx, smtplib

02 · interest_invoices.py

Creating sales invoices: quarterly interest on overdue balances

Reads each customer's overdue ledger balance, calculates the interest for the quarter and creates the interest invoices in one batch call.

/api-v1/organization

/api-v1/ledger

/api-v1/chart-accounts

/api-v1/sales-invoice/batch

Set your organisation ID before running

View the code

Download .py

02 · interest_invoices.py

Quarterly interest invoices on overdue balances

Python 3 · 326 lines · httpx

03 · import_contacts.py

Importing contacts from an Excel worksheet

Reads companies and people from an Excel file and creates them as Wyzio contacts in batches. Start from our sample file to see the expected columns.

/api-v1/contact/batch

03 · import_contacts.py

Importing contacts from an Excel worksheet

Python 3 · 262 lines · httpx, xlrd

Need another example?

Read the full documentation, or start from one of our Python examples.