API Documentation

Pkgsite provides a JSON API for accessing information about Go packages and modules.

Requests

All requests are GET requests whose first URL segment selects the request type. Except for search, the remaining segments specify a module or package path. Additional arguments are specified as query parameters.

Package paths are ambiguous: the same path a/b/c could be package c in module a/b or package b/c in module a. If both exist, the API returns an error with a list of possible modules in its candidates field. Make a follow-up request with the module query parameter to disambiguate. (Note: this behavior differs from the pkgsite UI, which selects the longest matching module path.)

Some routes accept an optional version query parameter. If missing, the latest version is chosen.

Some routes accept optional GOOS and GOARCH query parameters to select the desired build context of the documentation. If omitted, the default documentation build context is selected, typically linux/amd64.

Some routes accept a filter, specifying a regular expression. Only items that match the filter are returned. The documentation for each route specifies what constitutes a match for that route's items.

Most regular expression metacharacters will need to be percent-encoded. For example, to filter with the regular expression ^abc.*, write filter=%5Eabc.%2A. Go programs should call url.QueryEscape to encode filters (and all other query parameter values as well).

Responses

All routes return a JSON response. You can find a link to the corresponding Go type for a route in the documentation below. Errors are also returned as a JSON object, whose message field contains the error message.

You can access the machine-readable OpenAPI Specification.

Pagination

Some responses are paginated. Each response page has a nextPageToken, which is non-empty if there is another page of items. To retrieve the next page, repeat the original request verbatim, adding a token query parameter whose value is the next-page token from the response. Changing the request in any way other than providing a token may result in an error.

As long as nextPageToken is non-empty, there is another page, even if the current page has no items.

Routes

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL