--- title: "SDKs for JavaScript and Python" description: "pastdotdev is the official client of the Memory API, on npm and on PyPI. It sends your request bodies to the API as you wrote them." canonical: https://past.dev/docs/memory-api/sdks last-updated: 2026-11-18 --- # SDKs for JavaScript and Python > pastdotdev is the official client of the Memory API, on npm and on PyPI. It sends your request bodies to the API as you wrote them. Product: past.dev Memory API. Source: https://past.dev/docs/memory-api/sdks `pastdotdev` is one small client with the same calls in both languages. It adds the `Authorization` header, sends JSON and parses the response. It has no dependencies. The fields of a request and of a response are the ones in the [endpoint reference](/docs/memory-api/api-reference), with the same names in both languages. ### Install the SDK **TypeScript** ```typescript npm install pastdotdev ``` **Python** ```python pip install pastdotdev ``` The JavaScript package is an ES module and uses the `fetch` of the runtime, so it needs Node.js 18 or later. The Python package needs Python 3.9 or later. The packages are [pastdotdev on npm](https://www.npmjs.com/package/pastdotdev) and [pastdotdev on PyPI](https://pypi.org/project/pastdotdev/). ### Create the client Create a project key on the API keys screen of the console at https://app.past.dev and keep it in the environment of your server. Do not put the key in code that runs in a browser or on a phone. **TypeScript** ```typescript import PastClient from "pastdotdev"; const past = new PastClient({ apiKey: process.env.PAST_API_KEY }); ``` **Python** ```python import os from pastdotdev import PastClient past = PastClient(api_key=os.environ["PAST_API_KEY"]) ``` The client calls `https://api.past.dev`. `baseUrl` (`base_url` in Python) changes the host. ### Send a data point `ingest` with an object calls `POST /api/v1/ingest`. `content` is required. `timestamp` is when the content happened, and memory is dated with it. `id`, `label`, `metadata`, `audience`, `identity` and `idempotencyKey` are optional. The receipt carries `ingestionId`, `sourceId` and `status`. **TypeScript** ```typescript const receipt = await past.ingest({ id: "call-8821", content: "Budget for the Acme pilot moved to 40k.", label: "Email from Nadia", timestamp: "2026-07-28T16:00:00Z", identity: "nadia@acme.com", }); console.log(receipt.ingestionId, receipt.status); // "queued" ``` **Python** ```python receipt = past.ingest({ "id": "call-8821", "content": "Budget for the Acme pilot moved to 40k.", "label": "Email from Nadia", "timestamp": "2026-07-28T16:00:00Z", "identity": "nadia@acme.com", }) print(receipt["ingestionId"], receipt["status"]) # "queued" ``` ### Check that the send completed Ingestion is asynchronous, and a recall finds the memory of a send once the send is `completed`. `ingest` with an ingestion id calls `GET /api/v1/ingest/{ingestionId}` and returns its `status`: `processing`, `completed` or `failed`. A status read spends no credits. **TypeScript** ```typescript let send = await past.ingest(receipt.ingestionId); while (send.status === "processing") { await new Promise((resolve) => setTimeout(resolve, 2000)); send = await past.ingest(receipt.ingestionId); } if (send.status !== "completed") throw new Error(JSON.stringify(send.failure)); ``` **Python** ```python import time send = past.ingest(receipt["ingestionId"]) while send["status"] == "processing": time.sleep(2) send = past.ingest(receipt["ingestionId"]) if send["status"] != "completed": raise RuntimeError(send["failure"]) ``` ### Recall as one identity `recall` calls `POST /api/v1/recall`. `query` and `identity` are required: the identity is the user who asks, and the page holds only what that identity can read. Set it in your own code from the signed-in user. `level` or `maxTokens` sets the evidence budget, and `limit`, `sort`, `queryTimestamp`, `occurredFrom` and `occurredTo` are optional. **TypeScript** ```typescript const page = await past.recall({ query: "What is the Acme pilot budget?", identity: "nadia@acme.com", level: "low", }); for (const result of page.results) { console.log(result.occurredAt, result.content); for (const source of result.sources) console.log(" from", source.sourceId); } ``` **Python** ```python page = past.recall({ "query": "What is the Acme pilot budget?", "identity": "nadia@acme.com", "level": "low", }) for result in page["results"]: print(result["occurredAt"], result["content"]) for source in result["sources"]: print(" from", source["sourceId"]) ``` ### Handle a refusal A response that is not a success raises `PastError`. `status` is the HTTP status, and `body` is the parsed JSON of the refusal with its `code` and `debugMessage`. The [Errors page](/docs/memory-api/errors) lists each code. **TypeScript** ```typescript import PastClient, { PastError } from "pastdotdev"; try { await past.recall({ query: "What is the Acme pilot budget?" }); } catch (error) { if (!(error instanceof PastError)) throw error; console.error(error.status, error.body.code); // 400 "identity-required" } ``` **Python** ```python from pastdotdev import PastClient, PastError try: past.recall({"query": "What is the Acme pilot budget?"}) except PastError as error: print(error.status, error.body["code"]) # 400 "identity-required" ``` ### Other routes The client covers a send, the status of a send and a recall. Call every other route over HTTP with the same project key: `POST /api/v1/ingest/batch` for a backfill, `POST /api/v1/data-points/delete` for a deletion, and the identity and audience routes. The [endpoint reference](/docs/memory-api/api-reference) has a cURL sample for each one. ### SDK calls and their routes | Call | Route | | --- | --- | | `ingest(body)` | `POST /api/v1/ingest` | | `ingest(ingestionId)` | `GET /api/v1/ingest/{ingestionId}` | | `recall(body)` | `POST /api/v1/recall` | For a framework that has its own past.dev package, such as the Vercel AI SDK, CrewAI or LlamaIndex, use that package. The [Connectors page](/docs/memory-api/connectors) lists them.