crates.io
__Experimental API documentation for the [crates.io](https://crates.io/) package registry.__ This document describes the API used by the crates.io website,…
Fork copies the collection into your workspace, without the publisher's secrets, so you can add your own key and send requests. Star saves it to your starred APIs (Account › Marketplace) and helps others find it.
Overview
__Experimental API documentation for the crates.io
package registry.__
This document describes the API used by the crates.io website, cargo
client, and other third-party tools to interact with the crates.io
registry.
Before using this API, please read the
crates.io data access policy and ensure
that your use of the API complies with the policy.
__The API is under active development and may change at any time__,
though we will try to avoid breaking changes where possible.
Some parts of the API follow the "Registry Web API" spec documented
at
and can be considered stable.
Most parts of the API do not require authentication. The endpoints
that do require authentication are marked as such in the documentation,
with some requiring cookie authentication (usable only by the web UI)
and others requiring API token authentication (usable by cargo and
other clients).
Endpoints 53
categories
- GETList all categories.
/api/v1/categories - GETGet category metadata.
/api/v1/categories/:category - GETList all available category slugs.
/api/v1/category_slugs
users
- PUTMarks the email belonging to the given token as verified.
/api/v1/confirm/:email_token - PUTUpdate email notification settings for the authenticated user.
/api/v1/me/email_notificationsDeprecated. This endpoint was implemented for an experimental feature that was never fully implemented. It is now deprecated and will be removed in the future. - PUTRegenerate and send an email verification token.
/api/v1/users/:id/resend - GETGet user stats.
/api/v1/users/:id/statsThis currently only returns the total number of downloads for crates owned by the user. - GETFind user by login.
/api/v1/users/:user - PUTUpdate user settings.
/api/v1/users/:userThis endpoint allows users to update their email address and publish notifications settings. The id parameter needs to match the ID of the currently…
owners
- GETList crate owner invitations for a crate or user.
/api/v1/crate_owner_invitationsOnly pending invitations that haven't expired are returned. - PATCHAccept or decline a crate owner invitation.
/api/v1/crate_owner_invitations/:idOnly the invitee can accept or decline an invitation. - GETLists team owners of a crate.
/api/v1/crates/:name/owner_team - GETLists user owners of a crate.
/api/v1/crates/:name/owner_user - GETLists crate owners.
/api/v1/crates/:name/owners - PUTAdds crate owners.
/api/v1/crates/:name/ownersSupported owner names: username for a crates.io user, with confirmation for ambiguous or mismatched accounts. crates.io:username for a crates.io user.… - DELETERemoves crate owners.
/api/v1/crates/:name/ownersSupported owner names: username for a crates.io or GitHub user, if the owner selection is unambiguous. crates.io:username for a crates.io user.… - PUTAccept a crate owner invitation with a token.
/api/v1/me/crate_owner_invitations/accept/:token - PUTAccept or decline a crate owner invitation.
/api/v1/me/crate_owner_invitations/:crate_id
crates
- GETReturns a list of crates.
/api/v1/cratesCalled in a variety of scenarios in the front end, including: Alphabetical listing of crates List of crates under a specific owner Listing a user's followed… - GETGets crate metadata (for the `new` crate).
/api/v1/crates/newThis endpoint works around a small limitation in axum and is delegating to the GET /api/v1/crates/{name} endpoint internally. - GETGets crate metadata.
/api/v1/crates/:name - PATCHUpdates crate settings.
/api/v1/crates/:name - GETGet the download counts for a crate.
/api/v1/crates/:name/downloadsThis includes the per-day downloads for the last 90 days and for the latest 5 versions plus the sum of the rest. - PUTFollow a crate.
/api/v1/crates/:name/follow - DELETEUnfollow a crate.
/api/v1/crates/:name/follow - GETLists reverse dependencies of a crate.
/api/v1/crates/:name/reverse_dependencies
publish
- PUTPublishes a new crate/version.
/api/v1/crates/newUsed by cargo publish to publish a new crate or to publish a new version of an existing crate.
versions
- GETList all versions of a crate.
/api/v1/crates/:name/versions - GETGet crate version metadata.
/api/v1/crates/:name/:version - PATCHUpdate a crate version.
/api/v1/crates/:name/:versionThis endpoint allows updating the yanked state of a version, including a yank message. - GETGet crate version authors.
/api/v1/crates/:name/:version/authorsDeprecated. This endpoint was deprecated by RFC #3052 and returns an empty list for backwards compatibility reasons. - GETGet crate version dependencies.
/api/v1/crates/:name/:version/dependenciesThis information can also be obtained directly from the index. In addition to returning cached data from the index, this returns fields for id, version_id,… - GETDownload a crate version.
/api/v1/crates/:name/:version/downloadThis returns a URL to the location where the crate is stored. - GETGet the download counts for a crate version.
/api/v1/crates/:name/:version/downloadsThis includes the per-day downloads for the last 90 days. - GETGet the readme of a crate version.
/api/v1/crates/:name/:version/readme - PUTUnyank a crate version.
/api/v1/crates/:name/:version/unyank - DELETEYank a crate version.
/api/v1/crates/:name/:version/yankThis does not delete a crate version, it makes the crate version accessible only to crates that already have a Cargo.lock containing this version. Notes:…
keywords
- GETList all keywords.
/api/v1/keywords - GETGet keyword metadata.
/api/v1/keywords/:keyword
api_tokens
- GETFind API token by id.
/api/v1/me/tokens/:id - DELETERevoke API token.
/api/v1/me/tokens/:id - DELETERevoke the current API token.
/api/v1/tokens/currentThis endpoint revokes the API token that is used to authenticate the request.
other
- GETGet crates.io metadata.
/api/v1/site_metadataReturns the current deployed commit SHA1 (or unknown), and whether the system is in read-only mode. - GETGet front page data.
/api/v1/summaryThis endpoint returns a summary of the most important data for the front page of crates.io.
teams
- GETFind team by login.
/api/v1/teams/:team
trusted_publishing
- GETList Trusted Publishing configurations for GitHub Actions.
/api/v1/trusted_publishing/github_configs - POSTCreate a new Trusted Publishing configuration for GitHub Actions.
/api/v1/trusted_publishing/github_configs - DELETEDelete Trusted Publishing configuration for GitHub Actions.
/api/v1/trusted_publishing/github_configs/:id - GETList Trusted Publishing configurations for GitLab CI/CD.
/api/v1/trusted_publishing/gitlab_configs - POSTcreate_trustpub_gitlab_config
/api/v1/trusted_publishing/gitlab_configs - DELETEDelete Trusted Publishing configuration for GitLab CI/CD.
/api/v1/trusted_publishing/gitlab_configs/:id - POSTExchange an OIDC token for a temporary access token.
/api/v1/trusted_publishing/tokens - DELETERevoke a temporary access token.
/api/v1/trusted_publishing/tokensThe access token is expected to be passed in the Authorization header as a Bearer token, similar to how it is used in the publish endpoint.
API details
- Base URL
https://crates.iohttps://staging.crates.io- Authentication
- An API key in the authorization header
An API key in the cargo_session cookie
A bearer token in the Authorization header - Operations
- 53 operations on 42 pathsGET 29PUT 10DELETE 8POST 3PATCH 3
2 marked deprecated - Main resources
- versions 10owners 9crates 8trusted_publishing 8users 6api_tokens 3categories 3keywords 2other 2publish 1
- Response formats
application/json- Description format
- OpenAPI 3.1.0, API version
0.0.0 - Links
- OpenAPI document · Terms of service
- Listed from
- Crates's published OpenAPI description
How to test the crates.io in Swastik Codes
- Open the APISelect “Fork & run in Swastik Codes” on this page. Sign in or create a free account if asked.
- Fork it into your workspaceChoose a workspace. You get your own copy of the crates.io collection, without the publisher's secrets.
- Add your credentialsThis API uses an API key in the authorization header. Add yours in the collection's variables or an environment; the requests already reference it.
- Send a requestPick an endpoint, for example “List all categories.” (GET /api/v1/categories), and press Send. Check the response, add tests and run the whole collection with the runner.
Frequently asked questions
What is the crates.io?
__Experimental API documentation for the [crates.io](https://crates.io/) package registry.__ This document describes the API used by the crates.io website,… It is listed under Developer tools and has 53 endpoints.
Who publishes the crates.io?
It is listed from Crates's public API description (an OpenAPI document), not published by Crates on Swastik Codes. Anyone who controls crates.io can claim the profile by adding a DNS TXT record.
What is the base URL of the crates.io?
Its description lists 2 base URLs: https://crates.io, https://staging.crates.io. The first is the usual one; the others are typically sandbox or regional servers.
How do I authenticate with the crates.io?
It accepts 3 methods: an API key in the authorization header; an API key in the cargo_session cookie; A bearer token in the Authorization header.
How many endpoints does the crates.io have?
53 operations on 42 paths (29 GET, 10 PUT, 8 DELETE, 3 POST, 3 PATCH). The largest groups are versions, owners, crates, trusted_publishing.
Is forking the crates.io free?
Yes. Forking copies the collection into your workspace for free. It has been starred 0 times and forked 0 times.