Skip to main content
This walkthrough builds a small but realistic Python program end-to-end. You take a plain-text changelog, generate a loud headline with /v1/scream, emphasize key words in each entry with /v1/emphasize, and write the result to a markdown file ready to paste into a release announcement. Along the way you handle authentication, rate limits, and errors the way you would in a real codebase.

What you will build

Given an input file CHANGELOG.txt:
The tool produces RELEASE_NOTES.md:

Prerequisites

  • Python 3.10 or newer.
  • pip install requests.
  • An ACAAS API key. For the demo, any non-empty string works.
Set the key in your environment so it never lands in source control:

Step 1: A typed client wrapper

Start with a thin Client class. It centralizes the base URL, the auth header, and the retry logic so the rest of the program reads like business logic.
client.py
The retry loop covers the three failure shapes you actually see: rate limits (wait for the window), client errors (don’t retry — fix the input), and transient 5xx (exponential backoff).

Step 2: Endpoint methods

Add one method per endpoint you need. Each is a one-liner over _post.
client.py (continued)
Both endpoints return the same envelope, but you only need the result field for this tool. If you wanted to log which words were emphasized, return data instead and let the caller pick fields.

Step 3: The amplifier

With the client in place, the program logic is short.
amplify.py
Run it:

Step 4: Pacing for larger changelogs

The version above issues one request per entry, plus one for the headline. For a fifty-line changelog that fits comfortably inside the 100-request demo window. For a five-hundred-line changelog it does not. Add proactive pacing inspired by the rate limiting guide:
client.py (additional method)
Then call it inside the loop:
amplify.py (modified)
Now the tool slows itself down before it spills 429s into your logs.

Step 5: Smoke-test before shipping

A short test confirms each endpoint is reachable and your key works.
smoke.py
Run it once before integrating into your release pipeline.

What you learned

  • One client, one session. Reusing a requests.Session reuses TCP connections and centralizes headers.
  • Retry the recoverable, raise the rest. 429 and 5xx are worth retrying; 401, 413, and 422 are not.
  • Pace proactively when it matters. For one-off scripts, 429 retries are fine. For batches, check status first and stretch the tail of the window evenly.
  • Compose endpoints. A useful tool rarely calls one endpoint — /v1/scream for the headline, /v1/emphasize for the body, and they speak the same envelope shape.

Next steps

Errors reference

Every status code, with copy-paste handler patterns.

Rate limiting

Quota mechanics, the status ladder, and proactive pacing.

Experimental emphasis

The endpoint that picks emphasis for you. Tune emphasis_ratio.

Full API reference

Every endpoint, request, and response, in one place.