ecosyste-ms / packages

An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.
https://packages.ecosyste.ms
GNU Affero General Public License v3.0
25 stars 4 forks source link

Add API route for `/registries/{registry}/packages/lookup` OR bugfix `/packages/lookup` #867

Closed evamaxfield closed 1 month ago

evamaxfield commented 1 month ago

Goal

Find a package from a repository url + registry combination

Current Options

Currently, there is the basic /packages/lookup API route that supports adding both repository_url and ecosystem parameters, however the ecosystem parameter isn't being respected.

For example, if I try to find: https://github.com/allencellmodeling/aicsimageio

Using:

curl -X 'GET' \
  'https://packages.ecosyste.ms/api/v1/packages/lookup?repository_url=https%3A%2F%2Fgithub.com%2Fallencellmodeling%2Faicsimageio&ecosystem=pypi' \
  -H 'accept: application/json'

The first package I receive in the list is a go package which is explicitly what I wanted to filter out.

Let me know if I am doing something wrong with my query but I see three options for my current goal:

  1. have the current /packages/lookup query respect the ecosystem parameter
  2. add a /registries/{registry}/packages/lookup route
  3. I handle the registry filtering on my side after getting results back from the API
andrew commented 1 month ago

Nothing wrong, I think you found both a bug and a feature! I’ll get both of those sorted out for you today

andrew commented 1 month ago

Deploying a fix and a new endpoint for you now.

The new endpoint is: /registries/{registry}/lookup to avoid clashing with existing packages called lookup (like https://packages.ecosyste.ms/api/v1/registries/pypi.org/packages/lookup)

Example: https://packages.ecosyste.ms/api/v1/registries/pypi.org/lookup?repository_url=https%3A%2F%2Fgithub.com%2Fallencellmodeling%2Faicsimageio

and the ecosystem filter should work for when using repository_url now as well: https://packages.ecosyste.ms/api/v1/packages/lookup?repository_url=https%3A%2F%2Fgithub.com%2Fallencellmodeling%2Faicsimageio&ecosystem=pypi

thanks for reporting the bugs!

evamaxfield commented 1 month ago

Wow! Thanks so much for the fast turn around. Much appreciated ❤️