Read documentation or source code
Read a documentation page or an exact source file. The response identifies which kind was returned and includes the information needed to cite the page, package version, or repository commit.
Choose a target
For documentation, follow the read action from POST /v1/list, passing its target and non-null path unchanged. Browse hosted documentation with an explicit site: target; package and repository inventories include local documentation. Documentation results from POST /v1/searches also provide a docs_read_target, which you can pass as target without a path. An HTTP(S) target can include a fragment to select one indexed section.
For source code, pass both target and the exact target-relative file path. Use a package target such as crates:serde@1.0.0, or a supported public repository locator such as https://github.com/serde-rs/serde@master. Find paths with POST /v1/list, POST /v1/grep, or a code result from POST /v1/searches. Repository refs use @; a literal # is not supported in a code target.
When you have a read action, pass its target and non-null path unchanged. A scoped site target can use / to read its landing page. Preserve trailing slashes, query bytes, and literal percent bytes: they can identify distinct pages. Omit a null path.
Encode both values as query parameters. Encode a literal + as %2B, # as %23, and % as %25; an unencoded + is decoded as a space. For example, GET /v1/read?target=site%3Aexample.org%2Fguide&path=%2F reads that scope’s landing page. For a ready source target, absolute paths, dot segments, or trailing slashes are rejected with 400 VALIDATION_ERROR. Target resolution or indexing errors can occur before the source path is validated.
Interpret the result
Branch on the required kind field:
kind | Result |
|---|---|
documentation | Page identity, reusable docs_read_target, and exact crawled or repository source details. |
code | Target-relative and repository-root paths, binary status, and the requested, resolved, and served package version or repository commit. |
Documentation and source files use 1-based inclusive line ranges. If no bounds are supplied, the complete page or file is returned; for a documentation URL, its fragment selects an indexed section. Explicit bounds override that fragment. An end_line past the end is clamped. Empty documentation has null bounds, while an empty text file has bounds 0–0; binary code has null content and bounds. Explicit bounds require the content field group.
Selector catalogue
Use these selectors with the fields query parameter. Supplying fields replaces the defaults; kind and the identity and provenance fields for the returned branch remain present. See Choose what the response includes for the shared selection rules.
| Selector | Documentation result | Code result | Default |
|---|---|---|---|
metadata | Title, format, breadcrumbs, update and source context, and package ownership when known. | Detected language and total line count. | Yes |
content | Body, total lines, returned range, and resolved section anchor. | Body and returned range; values are null for binary files. | Yes |
Wait for code indexing
wait_timeout_ms controls how long to wait for code preparation, from 0 to 60000 milliseconds; the default is 20000. Use 0 when the caller prefers an immediate 503 PACKAGE_INDEXING response if code is not ready. Documentation reads do not use this budget for indexing.
For failures, branch on the problem response’s stable code. Correct malformed locators, paths, ranges, or selectors after 400 VALIDATION_ERROR. A 404 means the requested page, file, package, version, repository, or ref was not found. A 409 DOCUMENTATION_PAGE_OWNER_CONFLICT means the URL belongs to another documentation corpus. A 422 means the target exists but the requested section, file, package variant, or repository ref cannot produce one result. Respect Retry-After after 429 RATE_LIMITED; retry 503 PACKAGE_INDEXING later or with a positive wait budget. A 504 TIMEOUT does not guarantee that preparation stopped.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
Optional client attribution: trimmed printable ASCII, at most 80 bytes. Invalid optional values are dropped.
Optional client-version attribution: trimmed printable ASCII, at most 80 bytes. Invalid optional values are dropped.
Optional agent attribution: trimmed printable ASCII, at most 160 bytes. Invalid optional values are dropped.
Optional caller-defined session ID: one to 64 ASCII letters, digits, underscores or hyphens, preserved exactly. Supply the header at most once. Invalid supplied IDs return 400 INVALID_SESSION_ID; no session is created.
1 - 64^[A-Za-z0-9_-]{1,64}$Query Parameters
Required nonblank read target. Pass an emitted read action target unchanged: a documentation page ID or URL, a scoped site: target, a package in :[@] form, or a supported public repository locator. Repository refs use @. Encode literal + as %2B and literal # as %23.
Exact path from a read action, preserved after query decoding. Omit null or blank paths. For a scoped site, / reads its landing page; trailing slashes, query bytes, and literal percent bytes can identify distinct pages. Encode path as a query value without normalizing it. NUL and control characters are rejected. Pkgseer validates source-file paths within the addressed target; absolute paths, dot segments, and trailing slashes are invalid for source files.
Optional positive inclusive start line. Either bound overrides a documentation URL fragment and requires content.
1 <= x <= 2147483647Optional positive inclusive end line. It must not precede start_line and requires content.
1 <= x <= 2147483647Milliseconds to wait for code indexing, from 0 to 60000; defaults to 20000. Zero returns 503 PACKAGE_INDEXING immediately when code is not ready. Documentation reads do not use this budget for indexing. The overall request deadline includes the selected budget.
0 <= x <= 60000Comma-separated metadata and content response groups; both are selected by default. Supplying fields replaces the defaults. Explicit line bounds require content; kind and branch identity remain present.
Use the case-sensitive selectors in the catalogue. Order and duplicate selectors do not affect the result. ASCII whitespace around selectors is ignored. The decoded value is limited to 2048 UTF-8 bytes. Empty or unknown selectors and repeated fields query parameters return 400 VALIDATION_ERROR. A group does not include nested groups unless the catalogue says so; only listed wildcard bundles are supported.
Response
Documentation page or source file
- Option 1
- Option 2
A documentation page or source file, selected by kind.
Exact target accepted by a subsequent read.
Opaque documentation page ID.
documentation Mandatory source attribution and repository locator when applicable.
- Option 1
- Option 2
Show child attributes
Show child attributes
Page body and returned range, absent when unselected.
Show child attributes
Show child attributes
Atomic descriptive metadata, absent when unselected.
Show child attributes
Show child attributes