Export your library to a notebook

With the Library metadata API, write the ID, title, status, and timestamps of every document in your library to a file, one JSON object per line.

Run the export

Download the Python example and run it in the folder where you saved it. It uses Python 3’s standard library and the same documents:list key as the first request.

Bash
python3 focus-library.py > library.jsonl

Enter the key at the hidden terminal prompt. For an unattended job, supply FOCUS_API_KEY from its secret store. The script reads 100 documents per list request and follows next to the last page. Each line is one document’s ID, title, status, and timestamps. The file stays on your machine. An empty library produces an empty file.

JSON
{"id": "256e6440-bae3-4ec1-9e93-f2d195f0cbb4", "title": "Grid cells in the entorhinal cortex", "status": "ready", "createdAt": "2026-11-28T16:50:03.216Z", "updatedAt": "2026-11-28T16:50:03.216Z"}

What can go wrong

The script makes up to three attempts per page. It retries after a connection failure, or after a 429 or 503 response whose Retry-After is 60 seconds or less, and sends the page’s original Idempotency-Key each time. Any other error stops it with the status and code, for example HTTP 401 (invalid_api_key), and a nonzero exit status. The file can then hold a partial library, so import it only after the command exits successfully. Look up the code under Errors.

Count papers by status

In a Python notebook, count papers by processing status.

Python
import json
from collections import Counter

with open("library.jsonl", encoding="utf-8") as library:
    counts = Counter(json.loads(line)["status"] for line in library)
print(counts)

The output looks like Counter({'ready': 1, 'failed': 1, 'processing': 1}).