DEV Community

Decodo for Decodo

Posted on

How To Download a Documentation Site for Your AI Assistant

Coding agents tend to write Zendesk ticket scripts the way integrations worked for years, authenticating with an email address and an API token. That approach is now outdated. Since October 27, 2026, Zendesk accounts can’t create new API tokens, and the changelog sets April 30, 2027, as the end date for existing ones. In our tests, Claude Code (Sonnet 5) with no project instructions still wrote token-based scripts. It didn't learn about the change on its own, and even with web tools enabled, it made no web requests unless its instructions gave it a URL. This guide shows how to download a documentation site as Markdown with Decodo's Web Data API, so you can point your coding agent to the changelog before it writes any code.

TL;DR

  • Claude Code (Sonnet 5) chose OAuth in all 5 runs when 4 lines of instructions in CLAUDE.md told it to read the saved changelog first. When its instructions only said to search the docs, it chose deprecated API tokens in all 5.
  • One Decodo /crawl job downloaded all 205 unique pages in the selected sections of Zendesk's developer docs as Markdown in about a minute. For client-side rendered docs, the script sends pages to /scrape, which renders them.
  • A /map preview and the site's sitemap show which sections to select, so you crawl only the docs you need.

What you'll need

  • A Decodo account with the Web Data API free plan activated
  • Python 3.11 or later and requests
  • A coding agent, such as Claude Code, that reads CLAUDE.md or AGENTS.md

You'll build a reusable crawl_docs() function, run it on Zendesk's developer docs, and connect the docs to a coding agent in about 15 minutes.

What Decodo's /crawl does

Some docs sites publish a single-file copy, such as llms-full.txt, but it may cover only part of the site. As of November 2026, Zendesk offers an OpenAPI spec for its API reference, but its guides and changelog are available only as web pages.

/crawl downloads a site, or the sections you choose, in a single job. It starts from a URL, follows links and sitemaps, and returns each page as Markdown or HTML. It also handles retries, so you don't write that logic yourself. One API key works for /crawl and the other Web Data API endpoints, such as /scrape, /search, and /map. Each page is fetched through the same infrastructure as /scrape, including built-in proxy rotation, which helps on docs sites with anti-bot protection. The /crawl docs explain the parameters.

Your script runs /crawl, sends any pages that need JavaScript to /scrape, and saves the Markdown in your repo. A few lines in CLAUDE.md tell your coding agent how to use the files:

Decodo's _/crawl_ endpoint.

Step 1: Get an API key

Activate the free plan in the Decodo dashboard, open Web Data API, and copy the API key from the Playground tab:

Decodo's Web Scraping API, dashboard.

Then install Requests and set the key as an environment variable:

pip install requests
export DECODO_API_KEY="your_api_key"
Enter fullscreen mode Exit fullscreen mode

If you already have a Decodo Web Scraping API or Fast Search API token, the endpoint mapping shows the matching Web Data API endpoint and header.

Step 2: Choose the sections to crawl with /map

A /map call takes a start page and lists the site URLs it finds. The script below groups them by path so you can see which sections it found. Save this as map_preview.py, change the URL to your docs site's start page, and run python map_preview.py:

import os
from collections import Counter
from urllib.parse import urlparse

import requests

resp = requests.post(
    "https://data.decodo.com/v1/map",
    headers={"Authorization": f"Bearer {os.environ['DECODO_API_KEY']}"},
    json={"url": "https://developer.zendesk.com/api-reference/ticketing/introduction/"},
    timeout=120,
)
resp.raise_for_status()
result = resp.json()["results"][0]
links = [link["url"] for link in result["content"]["links"]]
print(len(links), "URLs")
sections = Counter("/".join(urlparse(u).path.split("/")[1:3]) for u in links)
for section, count in sections.most_common():
    print(f"{count:4}  /{section}")
Enter fullscreen mode Exit fullscreen mode

On Zendesk's API reference, the preview printed:

107 URLs
  91  /api-reference/ticketing
   8  /api-reference/introduction
   2  /documentation/ticketing
   1  /
   1  /documentation
   1  /api-reference
   1  /api-reference/custom-data
   1  /documentation/api-basics
   1  /zendesk/oas.yaml
Enter fullscreen mode Exit fullscreen mode

Use these paths to choose what to crawl. In Step 3, you list the sections you want in select_paths, as regular expressions such as ^/api-reference/ticketing/. From this preview, the Zendesk crawl selects /api-reference/ticketing, /api-reference/introduction, and the ticketing and api-basics guides under /documentation.

Then check the site's sitemap for more sections. Zendesk's sitemap, at /sitemap-index.xml, showed two more sections: the authentication guides and the changelog. Add them to select_paths too. The sitemap also shows pages you may want to exclude, such as apps that run inside Zendesk and two tool tutorials. This crawl puts them in exclude_paths.

Make sure the changelog or release notes are in select_paths, because the CLAUDE.md lines in Step 4 point the agent to them. If the docs keep old API versions side by side, such as /v1/ and /v2/, add the old version to exclude_paths too. The agent then reads only current pages.

The sitemap listed 203 in-scope pages for this crawl. The script sets a page limit of 400 to leave room for redirects and pages outside the sitemap. The limit is a maximum, and the crawl ends when no pages in scope are left. For your own site, set the limit above the number of pages you expect.

Step 3: Crawl the docs and save them as Markdown

Save this script as crawl_docs.py. It starts one crawl, polls its status every 15 seconds, and collects every chunk of results. Then it sends any page that needs JavaScript to /scrape for rendering and writes one file per page, plus ALL.md with all pages combined. To use it on another site, change the values at the end of the script:

import hashlib
import os
import re
import time
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
from urllib.parse import urlparse

import requests

API = "https://data.decodo.com/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['DECODO_API_KEY']}"}


def crawl_docs(url, out_dir, select, exclude=(), limit=400):
    job = requests.post(f"{API}/crawl", headers=HEADERS, timeout=60, json={
        "url": url,
        "output": "markdown",
        "select_paths": select,
        "exclude_paths": exclude,
        "limit": limit,
        "max_duration": 1800,
    })
    job.raise_for_status()
    job = job.json()

    while True:
        resp = requests.get(job["crawl_status"], headers=HEADERS, timeout=60)
        resp.raise_for_status()
        status = resp.json()
        print(f"{status['status']}: {status['completed']} done, {status['failed']} failed")
        if status["status"] != "pending":
            break
        time.sleep(15)

    # Results come in chunks, and each chunk links to the next
    pages, failed = {}, []
    next_url = job["results_content"]
    while next_url:
        resp = requests.get(next_url, headers=HEADERS, timeout=120)
        resp.raise_for_status()
        chunk = resp.json()
        for page in chunk["url"]:  # the API lists this chunk's pages under "url"
            if page["status"] == "done":
                pages[page["url"]] = page["content"]
            else:
                failed.append(page["url"])
        next_url = chunk.get("next")

    # Send placeholder pages, which need JavaScript rendering, to /scrape
    placeholders = [page_url for page_url, text in pages.items() if len(text) < 200]
    with ThreadPoolExecutor(max_workers=5) as pool:
        for page_url, text in pool.map(render, placeholders):
            pages[page_url] = text or pages[page_url]
    still_short = [page_url for page_url in placeholders if len(pages[page_url]) < 200]
    if still_short:
        print(f"{len(still_short)} pages are under 200 characters, so check them by hand")

    out = Path(out_dir)
    out.mkdir(parents=True, exist_ok=True)
    written = set()
    with open(out / "ALL.md", "w", encoding="utf-8") as combined:
        for page_url in sorted(pages):
            body = re.sub(r"\n{3,}", "\n\n", pages[page_url])
            # Old URLs that redirect return the same page, so keep one copy
            digest = hashlib.sha256(body.encode()).hexdigest()
            if digest in written:
                continue
            written.add(digest)
            text = f"---\nsource: {page_url}\n---\n\n{body}\n"
            path = out / to_relpath(page_url)
            path.parent.mkdir(parents=True, exist_ok=True)
            path.write_text(text, encoding="utf-8")
            combined.write(text + "\n")

    for page_url in failed:
        print("failed:", page_url)
    print(f"saved {len(written)} pages ({len(pages) - len(written)} duplicates skipped, "
          f"{len(placeholders) - len(still_short)} rendered with JavaScript), {len(failed)} failed, "
          f"{status['requests']} requests")
    if status["status"] != "done":
        raise SystemExit(f"stopped: the crawl ended as {status['status']}")


def render(page_url):
    """Fetch one page with /scrape, rendering its JavaScript first."""
    try:
        resp = requests.post(f"{API}/scrape", headers=HEADERS, timeout=180, json={
            "url": page_url,
            "headless": "html",
            "markdown": True,
        })
        resp.raise_for_status()
        return page_url, resp.json()["results"][0]["content"]
    except requests.RequestException:
        return page_url, None  # keep the crawled text, and the check below reports it


def to_relpath(url):
    """https://site.com/api-reference/ticketing/tickets -> api-reference/ticketing/tickets.md"""
    parsed = urlparse(url)
    path = parsed.path.strip("/") or "index"
    if parsed.query:  # keep ?lang=python and ?lang=node as separate files
        path += "_" + parsed.query
    return re.sub(r"[^\w./-]", "_", path) + ".md"


if __name__ == "__main__":
    # Change these values for your docs site
    crawl_docs(
        url="https://developer.zendesk.com/api-reference/ticketing/introduction/",
        out_dir="zendesk-docs",
        select=[
            r"^/api-reference/ticketing/",            # Support API reference
            r"^/api-reference/introduction/",         # auth, pagination, rate limits
            r"^/api-reference/changelog/",            # deprecation notices
            r"^/documentation/(ticketing|authentication|api-basics)/",
        ],
        exclude=[
            r"^/api-reference/ticketing/apps/",       # apps that run inside Zendesk
            # Postman and curl tutorials
            r"/(exploring-zendesk-apis-with-postman|installing-and-using-curl)/?$",
        ],
        limit=400,
    )
Enter fullscreen mode Exit fullscreen mode

Before you run it, check these settings:

  • select_paths and exclude_paths set the scope. Both take regular expressions that are matched against the URL path. The crawl always includes the start URL.
  • To match one exact page, end the pattern with /?$. It matches the path whether it ends with a slash or not.
  • limit sets the maximum number of pages, and max_duration sets the maximum run time in seconds. If a crawl reaches max_duration, it keeps the pages it collected and ends with the status truncated.
  • The script treats pages under 200 characters as placeholders. Raise that number if your site's placeholders are longer.
  • On a server, set callback_url instead of polling. Decodo sends a webhook, a POST request to that URL, when the crawl finishes, so your handler can collect the results immediately.

Running python crawl_docs.py took about a minute and printed:

pending: 0 done, 0 failed
pending: 166 done, 1 failed
done: 222 done, 4 failed
failed: https://developer.zendesk.com/api-reference/ticketing/business-rules/object_triggers
failed: https://developer.zendesk.com/api-reference/ticketing/jira_v2/jira_integration_links
failed: https://developer.zendesk.com/api-reference/ticketing/nps-api/introduction
failed: https://developer.zendesk.com/documentation/api-basics/getting-started/working-with-json
saved 205 pages (17 duplicates skipped, 0 rendered with JavaScript), 4 failed, 227 requests
Enter fullscreen mode Exit fullscreen mode

The status shows pending while the crawl runs. The zendesk-docs folder had every in-scope page that Zendesk's sitemap lists, including the changelog. It also had 2 guide pages that the sitemap doesn't list, which the crawl found by following links. The only failures were 4 broken links on Zendesk's site, which returned 404 in a browser too. The 17 duplicates were old Zendesk URLs that redirect to pages already in the folder, so the script kept one copy of each.

By default, /crawl fetches each page's HTML directly, which is the lower-cost option. Some docs sites use client-side rendering, where the browser builds each page. The script detects those pages by their short placeholder text, and render() sends them to /scrape with "headless": "html", which renders the JavaScript before converting the page to Markdown. On Xero's developer docs, which use client-side rendering, render() replaced 54 placeholder pages with full API reference pages.

A crawl this size fits in the free plan's monthly quota, and you pay only for successful requests. The requests figure in the output counts pages scraped successfully plus any sitemaps the crawl read. The billing page lists the rate per 1K requests for each plan, and the rate for pages rendered with JavaScript.

Step 4: Connect the docs to your coding agent

Running tree -L 2 zendesk-docs shows the layout:

zendesk-docs
├── ALL.md
├── api-reference
│   ├── changelog
│   ├── introduction
│   └── ticketing
└── documentation
    ├── api-basics
    ├── authentication
    └── ticketing
Enter fullscreen mode Exit fullscreen mode

The saved changelog keeps Zendesk's table as Markdown and contains the entry that the agent needs:

---
source: https://developer.zendesk.com/api-reference/changelog/changelog
---
[...]
| June 1, 2026 | Deprecated | [API tokens](/api-reference/introduction/security-and-auth/) | [...] Starting October 27, 2026, accounts can no longer create new API tokens through the UI or API. Existing active tokens will remain usable until April 30, 2027 unless they are deactivated. [...] |
Enter fullscreen mode Exit fullscreen mode

ALL.md is useful when a crawl is small enough to fit in a model's context window. This crawl's ALL.md is over 1.4M tokens, so let the agent search the folder and read only the pages it needs. Copy the zendesk-docs folder, without ALL.md, into your repo under docs/:

mkdir -p path/to/your-repo/docs
rsync -a --exclude ALL.md zendesk-docs/ path/to/your-repo/docs/zendesk-docs/
Enter fullscreen mode Exit fullscreen mode

Commit the folder so teammates and cloud agents get it too. Keep the repo private, because the docs are the vendor's content.

Then add these lines to CLAUDE.md, which Claude Code loads at the start of every session, or to AGENTS.md for agents that read that file:

This project calls the Zendesk Support API. Zendesk's developer docs are in
docs/zendesk-docs/ as Markdown, one file per page. Before writing Zendesk code,
read docs/zendesk-docs/api-reference/changelog/changelog.md for deprecations,
then search the docs for each endpoint and auth method you use.
Enter fullscreen mode Exit fullscreen mode

The instructions point the agent to the whole changelog, not to one entry. This way, it can also find deprecations you don't know about yet.

In each test setup below, Claude Code (Sonnet 5) got the same request 5 times. The request asked for a ticket script for a new Zendesk integration.

Setup Chose OAuth What the agent did
Docs and the instructions above 5 of 5 Read 3 to 5 pages, including the saved changelog in 4 runs and the ticket search reference in all 5
No docs in the repo 0 of 5 Used an API token. Enabling WebSearch and WebFetch didn't help, because it never used them
Docs and instructions that only said to search the docs 0 of 5 Read 2 to 4 pages and still used an API token
No docs, and instructions with the online changelog URL 3 of 5 Read pages with WebFetch, which returned a summary of each page instead of the full text

The agent used other pages too, so keep all the sections you crawled in the folder, not only the changelog. Other details from the runs:

  • In the run that didn't open the changelog, the agent read Zendesk's auth pages, which mark API tokens as deprecated.
  • In one run with the online URL, the WebFetch summary didn't include the API token entry.
  • In another run with the online URL, a summary of Zendesk's auth page said API tokens could still be created. The saved copy in the folder has the full text.

In a new run with the instructions above, Claude Code read the saved changelog first and explained its choice of credential:

How to download a documentation site for Your AI assistant?

For another vendor's API, use the same 4 lines with that vendor's name, docs folder, and the changelog or release notes path from your tree output.

Step 5: Keep the docs current

Vendors update their docs, so refresh your copy on a schedule. These commands rerun the crawl and copy the result with --delete, so pages the vendor removed are also removed from docs/. The script exits with an error unless the crawl ends as done, so rsync runs only after a finished crawl. A page that failed in this run disappears from docs/ too, so check the git status output before you commit:

rm -rf zendesk-docs && python crawl_docs.py &&
  rsync -a --delete --exclude ALL.md zendesk-docs/ path/to/your-repo/docs/zendesk-docs/
git -C path/to/your-repo status --short docs/
git -C path/to/your-repo diff docs/
Enter fullscreen mode Exit fullscreen mode

Check the changelog diff for new deprecations.

To refresh a single page between crawls, your agent can fetch it with /scrape and overwrite its file in docs/. Click Copy agent setup in the Playground tab, shown in the Step 1 screenshot, and paste the prompt into your agent. The prompt tells the agent to install Decodo's CLI and its Agent Skill, which is a set of instructions for using Decodo's API. It also tells the agent to store your key outside your source files.

Final thoughts

One Decodo crawl job downloads the docs sections you choose, and crawl_docs() saves them in a folder your agent can search. Four lines in CLAUDE.md then direct the agent to the changelog before it writes code. The free plan lets you try Decodo at no cost, so start with the docs for the API that your agent makes the most mistakes with.

Top comments (0)