Use this API to interact with the Cargo package registry, including its sparse index, registry configuration, and crate downloads. Generally these endpoints are used by Cargo itself and are not meant for manual consumption. For more information, see the package registry.

Get the sparse index for a Cargo crate (1-character name)

GET /api/v4/projects/{id}/packages/cargo/1/{package_name}

Returns newline-delimited JSON, one line per published version, most recently published first. Limited to the 500 most recently published versions.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
package_name
Path, required
StringThe cargo package name

Responses

CodeDescriptionSchema
200OKString (text/plain)
400Bad Request—
401Unauthorized—
403Forbidden—
404Not Found—

Get the sparse index for a Cargo crate (2-character name)

GET /api/v4/projects/{id}/packages/cargo/2/{package_name}

Returns newline-delimited JSON, one line per published version, most recently published first. Limited to the 500 most recently published versions.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
package_name
Path, required
StringThe cargo package name

Responses

CodeDescriptionSchema
200OKString (text/plain)
400Bad Request—
401Unauthorized—
403Forbidden—
404Not Found—

Get the sparse index for a Cargo crate (3-character name)

GET /api/v4/projects/{id}/packages/cargo/3/{first_char}/{package_name}

Returns newline-delimited JSON, one line per published version, most recently published first. Limited to the 500 most recently published versions.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
first_char
Path, required
StringFirst character of the cargo package name
package_name
Path, required
StringThe cargo package name

Responses

CodeDescriptionSchema
200OKString (text/plain)
400Bad Request—
401Unauthorized—
403Forbidden—
404Not Found—

Get config.json

GET /api/v4/projects/{id}/packages/cargo/config.json

This will be used by cargo for further requests

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project

Responses

CodeDescriptionSchema
200OK—
400Bad Request—
401Unauthorized—
403Forbidden—
404Not Found—

Download a Cargo crate

GET /api/v4/projects/{id}/packages/cargo/{package_name}/{package_version}/download

This endpoint serves the .crate file for a given package name and version

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
package_name
Path, required
StringThe cargo package name
package_version
Path, required
StringThe cargo package version

Responses

CodeDescriptionSchema
200OKString (binary) (application/octet-stream)
400Bad Request—
401Unauthorized—
403Forbidden—
404Not Found—

Get the sparse index for a Cargo crate (4+ character name)

GET /api/v4/projects/{id}/packages/cargo/{prefix_1}/{prefix_2}/{package_name}

Returns newline-delimited JSON, one line per published version, most recently published first. Limited to the 500 most recently published versions.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
prefix_1
Path, required
StringFirst two characters of the cargo package name
prefix_2
Path, required
StringNext two characters of the cargo package name
package_name
Path, required
StringThe cargo package name

Responses

CodeDescriptionSchema
200OKString (text/plain)
400Bad Request—
401Unauthorized—
403Forbidden—
404Not Found—