Example
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ User message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
'q': quit, Alt+Enter: newline
> read the Python example in https://readwise.io/reader_api and use it to retrieve my Reader documents in location
"later". Paging should work as described. Return them in a JSON format with keys source_url, title, created_at and
summary. You have my API key as READWISE_API_KEY env variable
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Model response ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Great! Here’s what I’ll do:
1. Scrape the official Readwise Reader API page for the Python example, ensuring I follow the latest recommendations.
2. Use your READWISE_API_KEY from the environment to connect.
3. Implement a function to retrieve your documents from the "later" location, handling pagination as specified.
4. For each document, extract source_url, title, created_at, and summary, and provide the results in JSON.
Let me first fetch the Python usage example from the Readwise Reader API documentation.
╭─ Code action ────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│1 frommcpgen.firecrawl.firecrawl_scrapeimportfirecrawl_scrape,Params│
│2 │
│3 # Scrape the markdown content of the API docs│
│4 url='https://readwise.io/reader_api'│
│5 params=Params(url=url,formats=['markdown'],onlyMainContent=True)│
│6 docs=firecrawl_scrape(params)│
│7 docs[:1800]# Preview beginning to check extraction│
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Accumulated token usage: input=2.61k, thinking=0, output=210, cache_write=0, cache_read=2.43k; Accumulated costs: 0.003
USD
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Execution result ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
'# Reader API\n\nThe Reader API just supports saving new documents to Reader and fetching your documents. We will add
more endpoints in the near future.\nIf you have any questions, please [reach out :)](mailto:api@readwise.io)\n\nLooking
for the API docs for the original Readwise? [See here.](https://readwise.io/api_deets)\n\n## Authentication\n\nSet a
header with key "Authorization" and value: "Token XXX" where XXX is your\nReadwise\naccess token. You (or your users)
can get that from here: [readwise.io/access\\_token](https://readwise.io/access_token)\n\nIf you want to check that a
token is valid, just make a GET request to\n`https://readwise.io/api/v2/auth/`\nwith the above header.\nYou should
receive a `204` response.\n\n\n## Document CREATE\n\n**Request**: `POST` to
`https://readwise.io/api/v3/save/`\n\n**Parameters:**\nA JSON object with the following keys:\n\n| Key | Type |
Description | Required |\n| --- | --- | --- | --- |\n| url | string | The document\'s unique URL. If you don\'t have
one, you can provide a made up value such as `https://yourapp.com#document1` | yes |\n| html | string | The document\'s
content, in valid html (see examples). If you don\'t provide this, we will try to scrape the URL you provided to fetch
html from the open web. | no |\n| should\\_clean\\_html | boolean | Only valid when `html` is provided. Pass `true` to
have us automatically clean the html and parse the metadata (title/author) of the document for you. By default, this
option is `false`. | no |\n| title | string | The document\'s title, it will overwrite the original title of the
document | no |\n| author | string | The document\'s author, it will overwrite the original author (if found<br> during
the parsing step) | no |\n| summary | string | Summary of the document | no |\n| published\\_date | date | A datetime
represen'
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Model response ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
I've successfully extracted the Readwise Reader API documentation and confirmed that it covers both authentication and
the endpoints you’ll need. Here’s a summary before I continue:
- Authentication: Pass your access token as an Authorization header: Authorization: Token YOUR_READWISE_API_KEY
- To list your documents, you use GET https://readwise.io/api/v3/list/
- The documentation describes pagination using the nextPageCursor value in the response, which you use in subsequent
requests as the pageCursor parameter.
Next, I’ll:
1. Pull the Python example for fetching documents, adapting it to retrieve from the "later" location.
2. Implement paging as described.
3. For each document, extract source_url, title, created_at, and summary, and present results in the JSON format you
specified.
Let me extract the exact Python fetching example so I can proceed with the implementation.
╭─ Code action ────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│1 # Search for Python code in the scraped documentation suggesting API usage for GET /list│
│2 importre│
│3 │
│4 python_blocks=re.findall(r'```python(.*?)```',docs,re.DOTALL)│
│5 python_blocks[:2]# Show first 2 code snippets for review│
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Accumulated token usage: input=5.99k, thinking=0, output=461, cache_write=0, cache_read=4.99k; Accumulated costs: 0.008
USD
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Execution result ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[' hljs\n\nimport requests\nrequests.post(\n url="https://readwise.io/api/v3/save/",\n headers={"Authorization":
"Token XXX"},\n json={\n "url": "https://example.com/article/",\n # No html is provided, so the url
will be scraped to get the document\'s content.\n "tags": ["tag3", "tag4"]\n }\n)\n\n',
' hljs\n\nimport datetime\nimport requests # This may need to be installed from pip\n\ntoken = \'XXX\'\n\ndef
fetch_reader_document_list_api(updated_after=None, location=None):\n full_data = []\n next_page_cursor = None\n
while True:\n params = {}\n if next_page_cursor:\n params[\'pageCursor\'] = next_page_cursor\n
if updated_after:\n params[\'updatedAfter\'] = updated_after\n if location:\n
params[\'location\'] = location\n print("Making export api request with params " + str(params) + "...")\n
response = requests.get(\n url="https://readwise.io/api/v3/list/",\n params=params,\n
headers={"Authorization": f"Token {token}"}, verify=False\n )\n
full_data.extend(response.json()[\'results\'])\n next_page_cursor = response.json().get(\'nextPageCursor\')\n
if not next_page_cursor:\n break\n return full_data\n\n# Get all of a user\'s documents from all
time\nall_data = fetch_reader_document_list_api()\n\n# Get all of a user\'s archived documents\narchived_data =
fetch_reader_document_list_api(location=\'archive\')\n\n# Later, if you want to get new documents updated after some
date, do this:\ndocs_after_date = datetime.datetime.now() - datetime.timedelta(days=1) # use your own stored
date\nnew_data = fetch_reader_document_list_api(docs_after_date.isoformat())\n\n']
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Model response ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
I've found the official Python code example for retrieving documents, including handling pagination as required. Here’s
the approach from the example (with paging handled by looping over nextPageCursor):
- A function fetch_reader_document_list_api accepts location (e.g., "later"), requests your documents page by page, and
loops until all results are retrieved.
- For each document, you can extract fields such as source_url, title, created_at, and summary.
Next, I will:
1. Implement and run code based on that example using your "later" location.
2. For each result, return only your requested fields: source_url, title, created_at, summary.
3. Output the results as a JSON array.
Let’s start this process now.
╭─ Code action ────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 1 importos│
│ 2 importrequests│
│ 3 │
│ 4 # Acquire API key from environment│
│ 5 READWISE_API_KEY=os.environ.get('READWISE_API_KEY')│
│ 6 │
│ 7 # Function to fetch all Reader documents for a given location, paging as needed│
│ 8 deffetch_reader_documents(location='later'):│
│ 9 full_data=[]│
│10 next_page_cursor=None│
│11 whileTrue:│
│12 params={}│
│13 ifnext_page_cursor:│
│14 params['pageCursor']=next_page_cursor│
│15 iflocation:│
│16 params['location']=location│
│17 response=requests.get(│
│18 url="https://readwise.io/api/v3/list/",│
│19 params=params,│
│20 headers={"Authorization":f"Token {READWISE_API_KEY}"},│
│21 timeout=30,│
│22 )│
│23 response.raise_for_status()│
│24 data=response.json()│
│25 full_data.extend(data['results'])│
│26 next_page_cursor=data.get('nextPageCursor')│
│27 ifnotnext_page_cursor:│
│28 break│
│29 returnfull_data│
│30 │
│31 # Now fetch and prune to the requested fields│
│32 defextract_fields(documents):│
│33 result=[]│
│34 fordocindocuments:│
│35 result.append({│
│36 'source_url':doc.get('source_url'),│
│37 'title':doc.get('title'),│
│38 'created_at':doc.get('created_at'),│
│39 'summary':doc.get('summary'),│
│40 })│
│41 returnresult│
│42 │
│43 docs=fetch_reader_documents('later')│
│44 out=extract_fields(docs)│
│45 out[:3]# Just preview first 3 due to possible length│
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Accumulated token usage: input=10.15k, thinking=0, output=977, cache_write=0, cache_read=7.68k; Accumulated costs: 0.017
USD
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Execution result ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[{'source_url': 'https://roocode.com/',
'title': 'Your AI Dev Team in VS Code',
'created_at': '2025-05-07T09:42:57.381316+00:00',
'summary': 'Roo Code is an open-source AI-powered coding assistant that integrates with VS Code, helping developers
write and fix code more efficiently. It supports multiple programming languages, allows for multi-file edits, and lets
users customize its features to fit their workflow. With its automation capabilities and command execution, Roo Code
empowers developers to streamline their coding process while maintaining control over their projects.'},
{'source_url': 'https://simonwillison.net/2025/Mar/19/vibe-coding/',
'title': 'Not all AI-assisted programming is vibe coding (but vibe coding rocks)',
'created_at': '2025-04-25T09:50:34.081882+00:00',
'summary': "Vibe coding is a fun, relaxed approach to programming using AI that allows for rapid experimentation
without much code review. However, it's important to distinguish vibe coding from responsible AI-assisted programming,
which requires careful consideration of code quality and security. While vibe coding can help beginners and experienced
developers alike, it should be used cautiously, especially for projects that could impact others."},
{'source_url': 'https://github.com/simonw/files-to-prompt',
'title': 'simonw/files-to-prompt: Concatenate a directory full of files into a single prompt for use with LLMs',
'created_at': '2025-04-25T09:41:50.635921+00:00',
'summary': 'The "files-to-prompt" tool allows users to combine multiple files from a directory into a single prompt
for large language models. Users can customize which files to include or ignore, and the output can be formatted in
different ways, such as Markdown or Claude XML. Installation is simple with pip, and the tool can also read file paths
from standard input.'}]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Model response ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Successfully retrieved your "later" Readwise Reader documents using your API key and the official API, including correct
handling of API paging. For each document, I extracted the fields: source_url, title, created_at, and summary.
Here’s a preview of the resulting JSON (first 3 items):
```json
[
{
"source_url": "https://roocode.com/",
"title": "Your AI Dev Team in VS Code",
"created_at": "2025-05-07T09:42:57.381316+00:00",
"summary": "Roo Code is an open-source AI-powered coding assistant that integrates with VS Code, helping developers
write and fix code more efficiently. It supports multiple programming languages, allows for multi-file edits, and lets
users customize its features to fit their workflow. With its automation capabilities and command execution, Roo Code
empowers developers to streamline their coding process while maintaining control over their projects."
},
{
"source_url": "https://simonwillison.net/2025/Mar/19/vibe-coding/",
"title": "Not all AI-assisted programming is vibe coding (but vibe coding rocks)",
"created_at": "2025-04-25T09:50:34.081882+00:00",
"summary": "Vibe coding is a fun, relaxed approach to programming using AI that allows for rapid experimentation
without much code review. However, it's important to distinguish vibe coding from responsible AI-assisted programming,
which requires careful consideration of code quality and security. While vibe coding can help beginners and experienced
developers alike, it should be used cautiously, especially for projects that could impact others."
},
{
"source_url": "https://github.com/simonw/files-to-prompt",
"title": "simonw/files-to-prompt: Concatenate a directory full of files into a single prompt for use with LLMs",
"created_at": "2025-04-25T09:41:50.635921+00:00",
"summary": "The \"files-to-prompt\" tool allows users to combine multiple files from a directory into a single
prompt for large language models. Users can customize which files to include or ignore, and the output can be formatted
in different ways, such as Markdown or Claude XML. Installation is simple with pip, and the tool can also read file
paths from standard input."
}
]
```
If you’d like the full output (all documents), let me know how you want to receive it (e.g., display, download as file,
further summarization, etc.).
Accumulated token usage: input=15.35k, thinking=0, output=1.52k, cache_write=0, cache_read=11.26k; Accumulated costs:
0.026 USD
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ User message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
'q': quit, Alt+Enter: newline
> show all docs in later
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Model response ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
╭─ Code action ────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│1 importjson│
│2 # Pretty-print all documents│
│3 print(json.dumps(out,indent=2))│
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Accumulated token usage: input=21.10k, thinking=0, output=1.55k, cache_write=0, cache_read=16.90k; Accumulated costs:
0.029 USD
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Execution result ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[
{
"source_url": "https://roocode.com/",
"title": "Your AI Dev Team in VS Code",
"created_at": "2025-05-07T09:42:57.381316+00:00",
"summary": "Roo Code is an open-source AI-powered coding assistant that integrates with VS Code, helping developers
write and fix code more efficiently. It supports multiple programming languages, allows for multi-file edits, and lets
users customize its features to fit their workflow. With its automation capabilities and command execution, Roo Code
empowers developers to streamline their coding process while maintaining control over their projects."
},
{
"source_url": "https://simonwillison.net/2025/Mar/19/vibe-coding/",
"title": "Not all AI-assisted programming is vibe coding (but vibe coding rocks)",
"created_at": "2025-04-25T09:50:34.081882+00:00",
"summary": "Vibe coding is a fun, relaxed approach to programming using AI that allows for rapid experimentation
without much code review. However, it's important to distinguish vibe coding from responsible AI-assisted programming,
which requires careful consideration of code quality and security. While vibe coding can help beginners and experienced
developers alike, it should be used cautiously, especially for projects that could impact others."
},
{
"source_url": "https://github.com/simonw/files-to-prompt",
"title": "simonw/files-to-prompt: Concatenate a directory full of files into a single prompt for use with LLMs",
"created_at": "2025-04-25T09:41:50.635921+00:00",
"summary": "The \"files-to-prompt\" tool allows users to combine multiple files from a directory into a single
prompt for large language models. Users can customize which files to include or ignore, and the output can be formatted
in different ways, such as Markdown or Claude XML. Installation is simple with pip, and the tool can also read file
paths from standard input."
},
{
"source_url": "https://x.com/karpathy/status/1915581920022585597/?s=09&t=W4RCcLqcJd0IXKuAukJitw&rw_tt_thread=True",
"title": "Noticing myself adopting a certain rhythm in AI-assisted coding (i.e",
"created_at": "2025-04-25T03:08:38.846417+00:00",
"summary": "Andrej Karpathy describes his process for AI-assisted coding, focusing on careful, incremental
development. He emphasizes the importance of understanding the context and exploring multiple approaches before
selecting one to implement. The goal is to learn and review thoroughly while managing the AI's suggestions cautiously,
highlighting the need for improved tools in this area."
},
{
"source_url": "https://www.anthropic.com/engineering/claude-code-best-practices",
"title": "Claude Code: Best practices for agentic coding",
"created_at": "2025-04-22T08:57:49.098560+00:00",
"summary": "Claude Code is a command line tool that helps engineers and researchers integrate the Claude AI into
their coding workflows. It allows users to customize prompts, interact with git, and streamline complex tasks by using
Markdown files and checklists. Best practices include providing specific instructions, using CLAUDE.md files for
context, and running multiple instances of Claude for collaborative tasks."
}
]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Model response ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Here are all your current "later" documents from Readwise Reader, including the requested fields: source_url, title,
created_at, and summary.
```json
[
{
"source_url": "https://roocode.com/",
"title": "Your AI Dev Team in VS Code",
"created_at": "2025-05-07T09:42:57.381316+00:00",
"summary": "Roo Code is an open-source AI-powered coding assistant that integrates with VS Code, helping developers
write and fix code more efficiently. It supports multiple programming languages, allows for multi-file edits, and lets
users customize its features to fit their workflow. With its automation capabilities and command execution, Roo Code
empowers developers to streamline their coding process while maintaining control over their projects."
},
{
"source_url": "https://simonwillison.net/2025/Mar/19/vibe-coding/",
"title": "Not all AI-assisted programming is vibe coding (but vibe coding rocks)",
"created_at": "2025-04-25T09:50:34.081882+00:00",
"summary": "Vibe coding is a fun, relaxed approach to programming using AI that allows for rapid experimentation
without much code review. However, it's important to distinguish vibe coding from responsible AI-assisted programming,
which requires careful consideration of code quality and security. While vibe coding can help beginners and experienced
developers alike, it should be used cautiously, especially for projects that could impact others."
},
{
"source_url": "https://github.com/simonw/files-to-prompt",
"title": "simonw/files-to-prompt: Concatenate a directory full of files into a single prompt for use with LLMs",
"created_at": "2025-04-25T09:41:50.635921+00:00",
"summary": "The \"files-to-prompt\" tool allows users to combine multiple files from a directory into a single
prompt for large language models. Users can customize which files to include or ignore, and the output can be formatted
in different ways, such as Markdown or Claude XML. Installation is simple with pip, and the tool can also read file
paths from standard input."
},
{
"source_url": "https://x.com/karpathy/status/1915581920022585597/?s=09&t=W4RCcLqcJd0IXKuAukJitw&rw_tt_thread=True",
"title": "Noticing myself adopting a certain rhythm in AI-assisted coding (i.e",
"created_at": "2025-04-25T03:08:38.846417+00:00",
"summary": "Andrej Karpathy describes his process for AI-assisted coding, focusing on careful, incremental
development. He emphasizes the importance of understanding the context and exploring multiple approaches before
selecting one to implement. The goal is to learn and review thoroughly while managing the AI's suggestions cautiously,
highlighting the need for improved tools in this area."
},
{
"source_url": "https://www.anthropic.com/engineering/claude-code-best-practices",
"title": "Claude Code: Best practices for agentic coding",
"created_at": "2025-04-22T08:57:49.098560+00:00",
"summary": "Claude Code is a command line tool that helps engineers and researchers integrate the Claude AI into
their coding workflows. It allows users to customize prompts, interact with git, and streamline complex tasks by using
Markdown files and checklists. Best practices include providing specific instructions, using CLAUDE.md files for
context, and running multiple instances of Claude for collaborative tasks."
}
]
```
If you want to save this as a file, send it elsewhere, or further process these results, please let me know!
Accumulated token usage: input=27.72k, thinking=0, output=2.37k, cache_write=0, cache_read=19.33k; Accumulated costs:
0.045 USD
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ User message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
'q': quit, Alt+Enter: newline
> q