Download Docs — User Guide
Download this documentation site as Markdown through the Carbon Arc Python SDK.
Use it to read the docs offline, search them locally, or feed them into your own
tools. Use client.docs to download every page, or one section.
The download always matches the live site: it is rebuilt every time the docs are published.
Setup
import os
from dotenv import load_dotenv
from carbonarc import CarbonArcClient
load_dotenv()
client = CarbonArcClient(
host="https://api.carbonarc.co",
token=os.getenv("CARBONARC_API_TOKEN_PROD"),
)
All docs download methods live under client.docs. Requires carbonarc 1.1.21 or later.
Use your usual API token; the docs are public, so no data access is needed.
Option 1 — Save every page to disk — download_all
path = client.docs.download_all(directory="carbonarc-docs")
print(path)
# e.g. /Users/you/project/carbonarc-docs
Behavior:
- Writes each page's Markdown (
.mdor.mdx) underdocs/<section>/, in the same folders as the site's sidebar, e.g.carbonarc-docs/docs/platform/rate-limits.md - Defaults to the current working directory when
directoryis omitted, and creates the folder if it does not exist - Overwrites files at the same path; pages removed from the site since an earlier download are left in place, so download into an empty folder for an exact copy
- Links between pages point at docs.carbonarc.ai
- Returns the absolute path to the folder
Including images and PDF reports
By default, images and PDFs are not downloaded, to keep the download small. Pages link to them on docs.carbonarc.ai instead, so they open whenever you are online.
To use them offline, save them beside docs/; the pages then link to the saved
copies:
include_images=Truesaves the images the pages use (about 500 MB) understatic/img/.include_pdfs=Truesaves the PDF reports the pages link to (about 120 MB) understatic/pdf/, such as each case study's full report.
path = client.docs.download_all(
directory="carbonarc-docs",
include_images=True,
include_pdfs=True,
)
Files already saved are not downloaded again, so if a download stops partway, run it again to pick up where it left off.
Option 2 — One section — download_folder
path = client.docs.download_folder("platform", directory="carbonarc-docs")
The section is one of "platform", "reference", "developers" or "tutorials".
Same layout and behavior as download_all; include_images and include_pdfs
download only the files that section uses.
Option 3 — Work in memory — get_all
get_all returns every page as the bytes of a zip archive, with the same
docs/<section>/... paths.
import io
import zipfile
zip_bytes = client.docs.get_all()
with zipfile.ZipFile(io.BytesIO(zip_bytes)) as z:
print(len(z.namelist()), "pages")
text = z.read("docs/platform/rate-limits.md").decode("utf-8")
What's in the download — get_manifest
get_manifest lists every page in the download without downloading it.
manifest = client.docs.get_manifest()
print(manifest["count"]) # number of pages
print(manifest["sections"]) # pages per section
for item in manifest["items"][:3]:
print(item["section"], item["path"], item["title"])
Each item has path, section, title, size and sha256. manifest["assets"]
lists the images (static/img/...) and PDFs (static/pdf/...) the pages use,
with the URL each one is downloaded from.
Method reference
| Method | Returns | Description |
|---|---|---|
download_all(directory=None, include_images=False, include_pdfs=False) | str | Writes every page; returns the folder path |
download_folder(folder, directory=None, include_images=False, include_pdfs=False) | str | Writes one section; returns the folder path |
get_all() | bytes | Every page as a zip archive |
get_manifest() | dict | Lists every page, image and PDF in the download |
Parameters
| Parameter | Type | Description |
|---|---|---|
folder | str | "platform", "reference", "developers" or "tutorials" |
directory | str, optional | Output folder. Defaults to "." |
include_images | bool, optional | Also download the images the pages use. Defaults to False |
include_pdfs | bool, optional | Also download the PDF reports the pages link to. Defaults to False |
Errors
| Error | Meaning |
|---|---|
ValueError | folder is not one of the four sections, or a downloaded path would land outside directory |
requests.exceptions.HTTPError | The server answered with an error, e.g. 429 for too many requests; retry later |
Other requests.exceptions.RequestException | Network problem, e.g. a timeout or lost connection |
OSError | File-system issue (permissions, disk full) |
import requests
try:
path = client.docs.download_all(directory="carbonarc-docs")
except requests.exceptions.HTTPError as e:
print(e.response.status_code, e.response.text)
except requests.exceptions.RequestException as e:
print("Network problem:", e)
Related
| Method | Use when |
|---|---|
client.docs.download_all() | You want the documentation itself, offline or in your own tools |
| MCP Search Docs tool | You want an answer to a question about the platform |