Skip to content

Add Package Search API Endpoint (Similar to npm Registry) #1095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
maliknajjar opened this issue May 4, 2025 · 3 comments
Closed

Add Package Search API Endpoint (Similar to npm Registry) #1095

maliknajjar opened this issue May 4, 2025 · 3 comments

Comments

@maliknajjar
Copy link
Contributor

It would be very useful to have an API endpoint that allows searching for packages in the JSR registry, similar to the functionality provided by the npm registry (e.g., https://registry.npmjs.org/-/v1/search). This would enable developers and tools to programmatically discover packages based on keywords, descriptions, or other metadata. and build useful tools around it.

Use cases include:

  • Building custom UIs or CLI tools that browse JSR packages
  • Integrating search capabilities into editors or IDEs
  • Automating dependency analysis or recommendations

If possible, it would be great to support:

  • Full-text search on name, description, and keywords
  • Pagination and sorting
  • Optional filters (e.g., author, recently updated)

Thanks for the great work on JSR—looking forward to seeing this feature considered!

@github-project-automation github-project-automation bot moved this to Needs Triage in JSR May 4, 2025
@AugustinMauroy
Copy link
Contributor

AugustinMauroy commented May 4, 2025

For package that contain test

curl "https://api.jsr.io/packages?query=test"

for pagination/limit you have:

curl "https://api.jsr.io/packages?query=test&limit=10&page=2"

if you wanna the openapi file go on https://api.jsr.io/.well-known/openapi

And if you are curious here the api endpoint source:

jsr/api/src/api/package.rs

Lines 199 to 229 in cfef9ed

#[instrument(name = "GET /api/packages", skip(req), err, fields(query))]
pub async fn global_list_handler(
req: Request<Body>,
) -> ApiResult<ApiList<ApiPackage>> {
let db = req.data::<Database>().unwrap();
let (start, limit) = pagination(&req);
// Strip '@' prefix so scopes can still be searched.
let maybe_search =
search(&req).map(|query| query.strip_prefix('@').unwrap_or(query));
if let Some(search) = maybe_search {
Span::current().record("query", search);
}
let github_repo_id = req
.query("gitHubRepoId")
.map(|github_repo_id| {
github_repo_id
.parse::<i64>()
.context("Failed to parse 'gitHubRepoId' query")
})
.transpose()?;
let (total, packages) = db
.list_packages(start, limit, maybe_search, github_repo_id, None)
.await?;
Ok(ApiList {
items: packages.into_iter().map(ApiPackage::from).collect(),
total,
})
}

@maliknajjar
Copy link
Contributor Author

wow .. why isnt this documented in the jsr API docs?
thanks

@github-project-automation github-project-automation bot moved this from Needs Triage to Done in JSR May 4, 2025
@AugustinMauroy
Copy link
Contributor

Jsr doc is oriented to "package" maintainer and user not for package manager maintainers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants