Skip to content

Python

anyrow: every endpoint, with a sync client and an async one, for Python 3.10 and later.

The anyrow package has two clients over the same methods: SDK for regular code and AsyncSDK for asyncio. Request bodies and responses are typed dictionaries.

Install

pip install anyrow

It needs Python 3.10 or later.

Create a client

import osfrom anyrow import SDK, ClientConfiganyrow = SDK(ClientConfig(    base_url="https://api.anyrow.ai",    bearer_token=os.environ["ANYROW_API_KEY"],    auth_header_prefix="ApiKey ",    timeout=30.0,  # seconds))

auth_header_prefix="ApiKey " sends the key as Authorization: ApiKey <key>, the scheme API keys use. For asyncio, build AsyncSDK from the same config and await each call.

Make a call

An operation's id is its method, with the last part in snake case (tableTemplate.projectList is anyrow.tableTemplate.project_list). Path parameters come first, in path order, then the body as a dictionary; query parameters are keyword arguments:

page = anyrow.row.list("proj_...", "tbl_...", limit=50)row = anyrow.row.create("proj_...", "tbl_...", {"vendor": "Acme", "total": 120})

Every method also takes timeout= and headers= for that one call.

Errors

A failed call raises. Every error is an APIError with status, message and the parsed error body in data; each status has its own class:

from anyrow import APIError, ForbiddenErrortry:    table = anyrow.table.get("proj_...", "tbl_...")except ForbiddenError:    print("The key lacks tables:read")except APIError as error:    print(error.status, error.data["error_key"])

The classes are BadRequestError (400), UnauthorizedError (401), ForbiddenError (403), NotFoundError (404), ConflictError (409), UnprocessableEntityError (422), RateLimitError (429), InternalServerError (500), BadGatewayError (502), ServiceUnavailableError (503) and GatewayTimeoutError (504); any other status raises APIStatusError.

Read every row

rows, cursor = [], Nonewhile True:    page = anyrow.row.list("proj_...", "tbl_...", limit=100, **({"cursor": cursor} if cursor else {}))    rows += page["rows"]    cursor = page["nextCursor"]    if not cursor:        break

Extract a document

with open("./invoice.txt") as invoice:    batch = anyrow.extract.table.once("proj_...", "tbl_...", {"text": invoice.read()})print(batch["status"], batch["result"])

Stream an extraction

AsyncSDK streams the server-sent events as they arrive:

import asyncioimport osfrom anyrow import AsyncSDK, ClientConfigasync def main():    anyrow = AsyncSDK(ClientConfig(        base_url="https://api.anyrow.ai",        bearer_token=os.environ["ANYROW_API_KEY"],        auth_header_prefix="ApiKey ",    ))    async for event in anyrow.extract.table.stream("proj_...", "tbl_...", {"text": "Invoice 42 from Acme"}):        print(event["event"], event["data"])asyncio.run(main())

Verify webhooks

Deliveries follow Standard Webhooks; verify them with the standardwebhooks package as the Webhooks guide shows.