Comments (15)
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.
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.
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.
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.
Strange, for me it works. Can you try to clear your cache?
from api.
Can you try to clear your cache?
Yes, that worked, cheers.
from api.
@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.
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.
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.
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.
@tomByrer Would this new format help you?
What other features we could get for v2?
from api.
"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.
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.
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.
@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)
- Version sorting HOT 10
- API returns no versions (urgent) HOT 5
- Move the API away from AppFog HOT 8
- Am I right to assume that I cannot get data for multiple librarys with one api call? HOT 4
- Searching by URL HOT 1
- jQuery failed to update latest beta1 HOT 2
- File paths HOT 14
- Incorrect author format for some CDNJS projects HOT 3
- pagination need? HOT 3
- The result order is not right HOT 3
- Default filename for specified version HOT 8
- API is not detecting new projects HOT 2
- Specify Content Security Policy? HOT 1
- API future HOT 3
- Add SRI to API HOT 1
- Add a download/hit count to the API HOT 7
- API endpoint down? HOT 2
- "bootstrap" alias is gone in v1 HOT 7
- Remove X-Requested-With
- Make sure logentries is utilized HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from api.