Giter Site home page Giter Site logo

(fuzzy) search by field about api HOT 15 CLOSED

jsdelivr avatar jsdelivr commented on May 24, 2024
(fuzzy) search by field

from api.

Comments (15)

bebraw avatar bebraw commented on May 24, 2024

You can get match for "AngularUI Team" with http://api.jsdelivr.com/v1/jsdelivr/libraries?author=AngularUI%20Team .

Could you please allow quoting?

I'm not so sure about quotes. If you encode your input right, the current method works just fine. Quotes might open a can of worms.

Wildcard search

We haven't settled on an approach yet. Now it's just a literal match.

What sort of searches do you need? Is there need for a global search?

I hope we can leverage some existing solution. Maybe we could go with regex?

from api.

tomByrer avatar tomByrer commented on May 24, 2024

You can get match for "AngularUI Team" with http://api.jsdelivr.com/v1/jsdelivr/libraries?author=AngularUI%20Team

Oh, that works great, no need for quotes! I or someone should document this.

What sort of searches do you need? Is there need for a global search?

My use-case is to insert <script src="http://CDN/latest/lib.js"> inside editors. JSBin's [Add Library] is a great example. It would be helpful for people to search for all jQuery or Angular plugins. Perhaps not everyone knows that 'yepnope''s project name is listed as "yepnope.js" on jsDelivr but "yepnope" on CDNJS. Though I see the need to search for a perfect match for 'jquery' if they don't want to pull up every plugin.
I can also see the API being used for web front-ends, like jsDelivr.com, an all-in-one CDN search, or a JavaScript library directory. So searching for the latest Angular-UI plug-in updates or what's new from tjholowaychuk is helpful.

I got an 'Express 500 error' for http://api.jsdelivr.com/v1/jsdelivr/libraries?assets=angular-ui.min.js.
I was looking to find the latest version for a particular file, to insert in online editors, or run from a local script to replace existing references with their latest versions on CDNs.

I hope we can leverage some existing solution. Maybe we could go with regex?

Looks like regex.test(array) is fastest, though perhaps array.indexof(regex) can work.
My initial impression of precompiling the regex may not be helpful; these are tight loops of the same query. Though perhaps later testing for universal precompiling, or optimizing select queries, would improve performance.

from api.

jimaek avatar jimaek commented on May 24, 2024

assets is an array, so you can't do it like you did. Maybe you can try this?

http://api.jsdelivr.com/v1/jsdelivr/libraries?mainfile=angular-ui.min.js

Otherwise @bebraw should explain how to pass a parameter to the array.

Also Juho added wildcard support. So you can also do this:

http://api.jsdelivr.com/v1/jsdelivr/libraries?name=yepnope*

from api.

tomByrer avatar tomByrer commented on May 24, 2024

Also Juho added wildcard support. So you can also do this:
http://api.jsdelivr.com/v1/jsdelivr/libraries?name=yepnope*

Oh cool, thanks! Unfortunately I get the empty set with http://api.jsdelivr.com/v1/cdnjs/libraries?name=yepnope*, though yep* works with both. I usually assume * = 0+ items.

Maybe you can try this? http://api.jsdelivr.com/v1/jsdelivr/libraries?mainfile=angular-ui.min.js

I can, but I can't find http://api.jsdelivr.com/v1/jsdelivr/libraries/lodash?lastversion&assets=lodash.underscore.js. I can skip this, since I can workaround it for now.
cheers

from api.

jimaek avatar jimaek commented on May 24, 2024

Strange, for me it works. Can you try to clear your cache?

from api.

tomByrer avatar tomByrer commented on May 24, 2024

Can you try to clear your cache?

Yes, that worked, cheers.

from api.

bebraw avatar bebraw commented on May 24, 2024

@tomByrer What's http://api.jsdelivr.com/v1/jsdelivr/libraries/lodash?lastversion&assets=lodash.underscore.js supposed to return? What are you trying to do? The query doesn't look valid to me.

from api.

jimaek avatar jimaek commented on May 24, 2024

I think he wanted to do this

http://api.jsdelivr.com/v1/jsdelivr/libraries?fields=lastversion&assets=lodash.underscore.js

So basically get the lastversion parameter from the project that has that filename in its assets.

from api.

tomByrer avatar tomByrer commented on May 24, 2024

Yes, what he said ^ :)
My use case is to help people refresh their asset URLs to the latest version.
Ideally, I'd like to also search for latest in branch, just like we can grab the file for latest 1.* or latest 1.10.* files. Though I don't want to grab the entire file, just build the hardcoded URL, so webdevs can approve a specific version before pushing before production. Most devs want to test before using, so not letting them verify the version changes is a bad idea.
A triggered build-tool script will help devs keep updated with little drama.

I understand if you feel my idea is out of scope. I could just get http://api.jsdelivr.com/v1/jsdelivr/libraries/lodash?fields=lastversion,assets & build what i want from there.

from api.

bebraw avatar bebraw commented on May 24, 2024

I understand if you feel my idea is out of scope. I could just get http://api.jsdelivr.com/v1/jsdelivr/libraries/lodash?fields=lastversion,assets & build what i want from there.

If it's fine, maybe go with that then. It's a little bit of extra work on your side as you need to process the assets.

I'm not a fan of the current format of assets by the way. What if instead of

      {
        "version": "2.1.0",
        "files": [
          "jquery.js",
          "jquery.min.js",
          "jquery.min.map"
        ]
      },

you could get something like

     "2.1.0": [
        "jquery.js",
        "jquery.min.js",
        "jquery.min.map"
      ]

Then you could do like

request.get('http://api.jsdelivr.com/v1/jsdelivr/libraries/lodash?fields=lastversion,assets', {json: true}, function(err, res, data) {
    var files = data.assets[data.lastversion];

    // operate with files now
});

Given it's a breaking change we would have to do v2. @jimaek What do you think?

from api.

jimaek avatar jimaek commented on May 24, 2024

@tomByrer Would this new format help you?

What other features we could get for v2?

from api.

tomByrer avatar tomByrer commented on May 24, 2024
"2.1.0": [
        "jquery.js",
        "jquery.min.js",
        "jquery.min.map"
      ]

does look sexier, & I always like smaller data transfers 👍 & thanks for the example!

What other features we could get for v2?

Would it be out of scope to search for what CDN hosts a particular project? That's why I was looking for better project searching. There are many hosted on one, but not the other. Versions differ very often.

// find what  React versions are hosted on all CDNs
http://api.jsdelivr.com/v2/libraries?assets=react.min.js&fields=cdn,name,versions
// new jQuery just released; who has it?
http://api.jsdelivr.com/v2/libraries?name=jquery&fields=cdn,lastversion

from api.

bebraw avatar bebraw commented on May 24, 2024

Would it be out of scope to search for what CDN hosts a particular project?

That could fit v2. As you suggested it could go to v2/libraries. The question is what should that return. What would you expect?

from api.

shahata avatar shahata commented on May 24, 2024

I think it makes sense to add a cdn field to each of your endpoints with its respective name:

http://api.jsdelivr.com/v1/jsdelivr/libraries --> all libraries have {cdn: 'jsdelivr'}
http://api.jsdelivr.com/v1/google/libraries --> all libraries have {cdn: 'google'}
http://api.jsdelivr.com/v1/cdnjs/libraries --> all libraries have {cdn: 'cdnjs'}

querying v2/libraries will simply return the concatenated result from all three endpoints

from api.

bebraw avatar bebraw commented on May 24, 2024

@shahata That's one option. I sketched out another alternative at #16. Then you would get aggregate result and you could access CDN specific results directly from that.

from api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.