MvG*_*MvG 30 node.js npm asp.net-web-api npmjs
我发现我经常对https://www.npmjs.com/上的搜索顺序和表现力不满意.我想应该有一种以编程方式查询使用服务器https://api.npmjs.org/或http://registry.npmjs.org/.但是怎么样?文件在哪里?
(或者是否有节点包来促进它?我知道SO不是关于工具或包的推荐,所以也许我不应该问这个问题,但是如果有一些工具,我可能会从那里读取API同样.)
MvG*_*MvG 21
当然,至少有一个工具可以与该注册表进行通信,这就是npm命令行工具本身.它的搜索示例首先更新索引的本地缓存副本,然后对其进行过滤.在update-index中,可以读到以URL结尾的URL /-/all 显然是特殊的.事实上,将其附加到registry.npmjs.org(故意不格式化为链接)将获取125M文件,这可能对您的浏览器来说太多了.幸运的是,缓存版本可以存储在~/.npm/registry.npmjs.org/-/all/.cache.json.从那里可以读取所有已知包的列表.然后可以继续更详细地查询每个这样的包.
事实上,npm search显然没有使用更复杂的方案表明这里没有太多的服务器端API.
在网上搜索提到的页面api.npmjs.org我发现可以从那里检索下载计数.我找到的所有其他文件都使用了这个单一的设施.
寻找替代方案,我也偶然发现了npmsearch.com,它提供了一些更多功能的搜索工具,并且有一些文档化的API.
Dip*_*Raj 16
最近发现了一个非常好的npm查询网站https://npms.io.他们还根据各种数据为每个包装提供质量点系统.
他们还将使用收集的有关项目的信息为每个包提供评分系统.最终得分是根据质量,维护,受欢迎程度和个性的四个不同方面计算的.
API Doc:https://api-docs.npms.io
Mar*_*tin 14
您始终可以使用NPM注册表客户端:https://github.com/npm/npm-registry-client.
如果仔细观察,可以获得API的端点.例如,为了得到包的dist-tag,你可以去/ - /package/packageName/dist-tags'
所以要获得babel-core dist标签,你可以去http://registry.npmjs.org/-/package/babel-core/dist-tags
https://skimdb.npmjs.com/registry/_all_docs
这是提取所有程序包名称的当前方法。
URL搜索是 http://registry.npmjs.com/-/v1/search?text=<searchstring>&size=20
如果找不到软件包,或者只是一起破解Shell脚本,则注册表git仓库中的Registry API Docs包含有关Search API和搜索限定符的详细信息。
如果要在公共注册表中查找最流行的不安全软件包,请运行:
wget -qO - "http://registry.npmjs.com/-/v1/search?text=is:insecure&popularity=1.0&size=1"
Run Code Online (Sandbox Code Playgroud)
上面的代码使用is:insecure搜索限定符而没有任何其他文本条件,并size=1在popularity=1.0(最流行的)地方获取结果。
在存储库中的docs目录中检查许多其他有用的东西,例如:
文档现在在这里:https : //github.com/npm/registry/blob/master/docs/download-counts.md
获取给定时间段内所有包或特定包的总下载量。
GET https://api.npmjs.org/downloads/point/{period}[/{package}]
小智 5
看一下sinopia注册表界面:https : //github.com/rlidwka/sinopia/blob/master/lib/index-api.js。npm客户端的默认注册表为https://registry.npmjs.org(在控制台上尝试:npm config ls -l)。因此,您可以尝试以下操作(引用sinopia API)以获取有关react 15.0.2的数据
https://registry.npmjs.org/react/15.0.2
您可以在以下 GitHub 存储库中找到官方公共 NPM 注册表 API 的文档:https : //github.com/npm/registry
可以在此处找到搜索端点的文档:https : //github.com/npm/registry/blob/master/docs/REGISTRY-API.md#get-v1search
接受以下查询参数:文本、大小、质量、流行度、维护
curl -sL 'https://registry.npmjs.org/-/v1/search?text=react-native&size=5' | jq
Run Code Online (Sandbox Code Playgroud)
这里我们curl用来发出 API 请求,并jq格式化 JSON 响应。返回以下输出:
{
"objects": [
{
"package": {
"name": "react-native",
"scope": "unscoped",
"version": "0.62.2",
"description": "A framework for building native apps using React",
"date": "2020-04-08T17:08:19.985Z",
"links": {
"npm": "https://www.npmjs.com/package/react-native",
"homepage": "https://github.com/facebook/react-native#readme",
"repository": "https://github.com/facebook/react-native",
"bugs": "https://github.com/facebook/react-native/issues"
},
"publisher": {
"username": "react-native-bot",
"email": "opensource+react-native-bot@fb.com"
},
"maintainers": [
{
"username": "cpojer",
"email": "christoph.pojer@gmail.com"
},
{
"username": "fb",
"email": "opensource+npm@fb.com"
},
{
"username": "grabbou",
"email": "grabbou@gmail.com"
},
{
"username": "hectorramos",
"email": "hector@hectorramos.com"
},
{
"username": "react-native-bot",
"email": "opensource+react-native-bot@fb.com"
}
]
},
"flags": {
"unstable": true
},
"score": {
"final": 0.4604636166574407,
"detail": {
"quality": 0.5886895871400879,
"popularity": 0.47768592528213616,
"maintenance": 0.3333333333333333
}
},
"searchScore": 100000.47
},
{
"package": {
"name": "react-native-svg",
"scope": "unscoped",
"version": "12.1.0",
"description": "SVG library for react-native",
"keywords": [
"react-component",
"react-native",
"ios",
"android",
"SVG",
"ART",
"VML",
"gradient"
],
"date": "2020-04-09T23:50:28.358Z",
"links": {
"npm": "https://www.npmjs.com/package/react-native-svg",
"homepage": "https://github.com/react-native-community/react-native-svg",
"repository": "https://github.com/react-native-community/react-native-svg",
"bugs": "https://github.com/react-native-community/react-native-svg/issues"
},
"publisher": {
"username": "msand",
"email": "msand@abo.fi"
},
"maintainers": [
{
"username": "brentvatne",
"email": "brentvatne@gmail.com"
},
{
"username": "dustin.savery",
"email": "dustin.savery@gmail.com"
},
{
"username": "magicismight",
"email": "master@horcrux.cn"
},
{
"username": "msand",
"email": "msand@abo.fi"
}
]
},
"score": {
"final": 0.5244501419238121,
"detail": {
"quality": 0.9582364654638059,
"popularity": 0.34375010176572474,
"maintenance": 0.3333333333333333
}
},
"searchScore": 0.031369504
},
{
"package": {
"name": "react-native-device-info",
"scope": "unscoped",
"version": "5.6.1",
"description": "Get device information using react-native",
"keywords": [
"react-component",
"react-native",
"ios",
"android",
"windows",
"device",
"events",
"cocoapod"
],
"date": "2020-05-27T18:33:11.715Z",
"links": {
"npm": "https://www.npmjs.com/package/react-native-device-info",
"homepage": "https://github.com/react-native-community/react-native-device-info#readme",
"repository": "https://github.com/react-native-community/react-native-device-info",
"bugs": "https://github.com/react-native-community/react-native-device-info/issues"
},
"author": {
"name": "Rebecca Hughes",
"email": "rebecca@learnium.net",
"url": "https://github.com/rebeccahughes"
},
"publisher": {
"username": "mikehardy",
"email": "npmjs@mikehardy.net"
},
"maintainers": [
{
"username": "gantman",
"email": "gantman+npm@gmail.com"
},
{
"username": "jeroenbourgois",
"email": "info@jeroenbourgois.be"
},
{
"username": "lilach",
"email": "i.am.red@gmail.com"
},
{
"username": "machour",
"email": "machour@gmail.com"
},
{
"username": "rebeccahughes",
"email": "rebeccahughes1@outlook.com"
}
]
},
"score": {
"final": 0.5102794746987024,
"detail": {
"quality": 0.9614895473985808,
"popularity": 0.3004741251784613,
"maintenance": 0.3333333333333333
}
},
"searchScore": 0.016712856
},
{
"package": {
"name": "css-to-react-native",
"scope": "unscoped",
"version": "3.0.0",
"description": "Convert CSS text to a React Native stylesheet object",
"keywords": [
"styled-components",
"React",
"ReactNative",
"styles",
"CSS"
],
"date": "2019-10-10T17:46:00.297Z",
"links": {
"npm": "https://www.npmjs.com/package/css-to-react-native",
"homepage": "https://github.com/styled-components/css-to-react-native#readme",
"repository": "https://github.com/styled-components/css-to-react-native",
"bugs": "https://github.com/styled-components/css-to-react-native/issues"
},
"author": {
"name": "Jacob Parker"
},
"publisher": {
"username": "jacobp100",
"email": "jacobparker1992@gmail.com"
},
"maintainers": [
{
"username": "jacobp100",
"email": "jacobparker1992@gmail.com"
},
{
"username": "kristerkari",
"email": "krister@sent.at"
},
{
"username": "mxstbr",
"email": "npm@mxstbr.com"
}
]
},
"score": {
"final": 0.4836548888489432,
"detail": {
"quality": 0.8524860977159072,
"popularity": 0.39264581380833835,
"maintenance": 0.25852292771786467
}
},
"searchScore": 0.013077582
},
{
"package": {
"name": "react-native-elements",
"scope": "unscoped",
"version": "2.0.4",
"description": "React Native Elements & UI Toolkit",
"keywords": [
"react-native",
"reactjs",
"reactnative",
"bootstrap"
],
"date": "2020-06-30T02:30:34.882Z",
"links": {
"npm": "https://www.npmjs.com/package/react-native-elements",
"homepage": "https://react-native-elements.github.io/react-native-elements/",
"repository": "https://github.com/react-native-elements/react-native-elements",
"bugs": "https://github.com/react-native-elements/react-native-elements/issues"
},
"author": {
"name": "Nader Dabit & Monte Thakkar"
},
"publisher": {
"username": "flyingcircle",
"email": "jeremyelijah@live.com"
},
"maintainers": [
{
"username": "dabit3",
"email": "dabit3@gmail.com"
},
{
"username": "iroachie",
"email": "kroach.work@gmail.com"
},
{
"username": "monte9",
"email": "mthakkar@mail.sfsu.edu"
}
]
},
"score": {
"final": 0.4921277780507845,
"detail": {
"quality": 0.9218028296308819,
"popularity": 0.28262932141386665,
"maintenance": 0.3333333333333333
}
},
"searchScore": 0.011005878
}
],
"total": 26290,
"time": "Wed Jul 08 2020 05:02:14 GMT+0000 (UTC)"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14511 次 |
| 最近记录: |