Skip to main content
The Pulse SDKs for Python and TypeScript cover every route of the API. They send your API key and the Pulse-Version: 2 header on every request, and return typed results. Install pulse-ai from PyPI for Python, or @pulse-software/sdk from npm for TypeScript:

Create a client

This code creates a client with the API key in the PULSE_API_KEY environment variable:
For asyncio, Python also has AsyncPulse. It takes the same arguments and has the same calls, which you await.

Call an endpoint

Each endpoint is a group on the client, and every group has the same four calls. For Parse: classify, extract, split, tables, charts, pipeline and parse.batch work the same way. Saved configs sit in client.<endpoint>.configs, such as client.extract.configs. Webhooks sit in client.webhook, usage in client.usage.get(), and organization settings in client.settings.org.

Names and types

  • Python uses the API’s field names, with a trailing underscore where a name clashes with Python: async_, from_ on usage.get, and json_ on a table’s content.
  • TypeScript uses camelCase, such as fileUrl, and sends the API’s names for you.
  • A file is an open file or bytes in Python, and a stream, Buffer or Blob in TypeScript.
  • To read a response’s headers, such as the Link header on a page of a batch’s manifest, use the raw response. In Python, client.parse.batch.with_raw_response.get_result(...) returns .data and .headers. In TypeScript, .withRawResponse() on a call returns { data, rawResponse }.

Errors

A failed request raises an error that carries the response’s status, headers and body. In Python it’s ApiError, from pulse.core.api_error, with status_code, headers and body. In TypeScript it’s PulseError, with statusCode, rawResponse.headers and body. The body is the error’s problem details: branch on its code, and quote its request_id to support. Errors and retries explains each status and what to do about it.

Retries

The SDKs never retry a request on their own, and the max_retries (Python) and maxRetries (TypeScript) options have no effect. Add retries in your own code. Reads are safe to retry: reading a job’s status or result never starts a job or costs credits. In an organization that deletes each result the first time it’s read, a retried result read gets 410 if the first read reached Pulse. This helper retries a read after a network error, a 429 or a 5xx, and honors Retry-After:
client is the client from above, and the parse id is one a run returned. A job’s run is different. When a run fails with a 5xx or times out, Pulse may already have started the job: Send long work with async: true. The run then returns the job’s id within seconds, so a timeout is unlikely.
Never send a run again after a 5xx or a timeout without first checking whether its job exists. A second run starts a second job, and both are billed when they complete.

Timeouts

Calls have no timeout by default, so a call without async waits until its job ends or the connection closes. To set one, pass timeout (Python) or timeoutInSeconds (TypeScript), in seconds, when you create the client.