cdnjs / api-server

📡 API server for api.cdnjs.com - The #1 free and open source CDN built to make life easier for developers.
https://api.cdnjs.com
MIT License
89 stars 38 forks source link

parmas 'search' is not correct?? #71

Closed bigrain220 closed 2 years ago

bigrain220 commented 2 years ago

image

i want to get the same data as the picture show from you website, so i send address:''https://api.cdnjs.com/libraries?search=jquery&limit=5". But it doesnot work. The data returned is not correct. what should i do? help me please!

MattIPv4 commented 2 years ago

👋 You can take a look at the code doing the API search here, it is just making a call to Algolia: https://github.com/cdnjs/api-server/blob/master/routes/libraries.js

Similarly, you can compare the code doing the search in the website here, it is also just making a call to Algolia: https://github.com/cdnjs/static-website/blob/master/components/search/inline_search.vue

The key difference is that the API uses browseObjects to allow fetching of every result programmatically from Algolia, whereas the client uses a pure search which is much more restricted in terms of the number of results that are returned. I suspect that doing a pure search introduces other ranking factors that browserObjects does not consider.

MattIPv4 commented 2 years ago

Closing as intended behaviour.