Registries

crates.io

The crates.io API across four endpoints, with yanked versions as a status and docs.rs as the documentation home.
IDcargo02 / 6keyless · crates.io
Registry

crates.io

  • CargoRegistry
  • pkg:cargo

Crate, versions, dependencies and owners across four endpoints. yanked as a status, docs.rs for docs.

API
crates.io
Marks
yanked
Maintainers
owner users

Lookups

Access

Createcreate("cargo")
Import@agntn/registries/registries/cargo
PURLpkg:cargo/name
Trypkg:cargo/serde in the explorer

Address it

ts
await fetchPackageFromPURL("pkg:cargo/serde");
await fetchDependenciesFromPURL("pkg:cargo/serde@1.0.229");

Crates have no namespace. Names are used as they are.

What it reads

CallEndpoint
fetchPackageGET /api/v1/crates/{name}
fetchVersionsthe same, versions array
fetchDependenciesGET /api/v1/crates/{name}/{version}/dependencies
fetchMaintainersGET /api/v1/crates/{name}/owner_user

latestVersion is max_stable_version, with max_version as the fallback for crates that only have pre-releases. documentation is the crate's own docs link, repository and homepage come straight from the crate. metadata carries downloads, recent downloads, categories and creation and update dates.

Versions

Every version has publishedAt from created_at, integrity as sha256- plus the checksum, and its own license. A yanked version has status: "yanked". metadata carries the crate size, the feature map and the downloads of that version.

Dependencies

crates.io kindscope
normalruntime
devdevelopment
buildbuild

optional is the crate's own optional flag. Dependencies that apply to one target only are included with no marker; the target is not surfaced.

Maintainers

Owner users, each with a login, a name and a URL. Owner teams are not listed; the endpoint only returns users.

URLs

ts
urls.registry("serde"); // https://crates.io/crates/serde
urls.download("serde", "1.0.229"); // https://crates.io/api/v1/crates/serde/1.0.229/download
urls.documentation("serde", "1.0.229"); // https://docs.rs/serde/1.0.229
urls.readme("serde", "1.0.229"); // https://crates.io/api/v1/crates/serde/1.0.229/readme

Gotchas

  • crates.io requires a User-Agent and rate limits anonymous clients. The default client sends agntn-registries/<version> (+https://github.com/agntn/registries) with the installed version; set your own through new Client({ userAgent }) if you make many calls.
  • max_stable_version can be older than max_version when the newest release is a pre-release; latestVersion follows the stable one on purpose.
  • The dependencies endpoint answers per version. Asking for a version that does not exist is a NotFoundError with the version attached.

Where it lives

src/registries/cargo.ts.