jsdelivr / api

DEPRECATED - API for public CDNs
http://api.jsdelivr.com
MIT License
113 stars 29 forks source link

Closest matching #78

Closed megawac closed 9 years ago

megawac commented 9 years ago

A query endpoint to find the closest match would be extremely convenient (current use case is duckduckgo spice answers).

What this would involve is determining the library that matches a query as close as possible (e.g. jwuery may match jquery if jwuery is not a library). Another thing this should support is searching for plugins

/search?name=jquery carousel => jquery.carousel
/search?name=jquery-carousel => jquery.carousel

There should be an arbitrary threshold to cut off in accurate matches based on levenshtein scores. I'd say Math.min(query.length / 2, 4)

Imagining the endpoint would be

http://api.jsdelivr.com/v2/jsdelivr/find?name={lib}

I'm imagining this returning a single result

jimaek commented 9 years ago

What would be the response? Just the correct project name to further query using http://api.jsdelivr.com/v2/jsdelivr/{correctName}?

megawac commented 9 years ago

Yep, that's what I'm imagining

jimaek commented 9 years ago

What if multiple projects match the request? Do we return all of them? Just the first one? How to prioritize?

megawac commented 9 years ago

I think it should always return the closest match (potentially faster) and something similar to this already exists (but isn't the same /libraries?name=*jq).

An additional endpoint to consider is fuzzymatching (but I don't think thats worthwhile (let the user download the libraries locally))

jimaek commented 9 years ago

http://api.jsdelivr.com/v1/jsdelivr/libraries?name=*jq* Returns like 15 projects with full data :)

Your solution is going to return only 1 and only the name? Like this?

{

    "name": "jquery.validation.unobtrusive"
}
END
megawac commented 9 years ago

I was thinking with full data (for the DDG use case)

jimaek commented 9 years ago

If its going to return full data then maybe it makes no sense to use a separate endpoint? This way it would be cleaner http://api.jsdelivr.com/v2/jsdelivr/{searchQuery}

megawac commented 9 years ago

http://api.jsdelivr.com/v2/jsdelivr/{searchQuery} or http://api.jsdelivr.com/v2/jsdelivr/name={query} ?

jimaek commented 9 years ago

Its the same thing I believe https://db.tt/QqVwFcmA

megawac commented 9 years ago

K but this is a different endpoint

On Mon, Jun 1, 2015 at 3:00 PM, Dmitriy Akulov notifications@github.com wrote:

Its the same thing I believe https://db.tt/QqVwFcmA

— Reply to this email directly or view it on GitHub https://github.com/jsdelivr/api/issues/78#issuecomment-107671874.

jimaek commented 9 years ago

Ok, then I guess http://api.jsdelivr.com/v2/jsdelivr/name={query} makes more sense. What do you think?

megawac commented 9 years ago

Agreed!

On Mon, Jun 1, 2015 at 3:25 PM, Dmitriy Akulov notifications@github.com wrote:

Ok, then I guess http://api.jsdelivr.com/v2/jsdelivr/name={query} makes more sense. What do you think?

— Reply to this email directly or view it on GitHub https://github.com/jsdelivr/api/issues/78#issuecomment-107677694.