From 038736dd605de12aed7d92edaf23db54eea3893f Mon Sep 17 00:00:00 2001 From: elrrrrrrr Date: Mon, 3 Jun 2024 22:51:46 +0800 Subject: [PATCH] chore: trends api (#697) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 📚 add doc for the trends API. --------- * 📚 添加 trends api 相关文档 ## Summary by CodeRabbit - **Documentation** - Added sections for `[Token]` and `[Trend]` in the Registry API documentation. - Introduced a new endpoint `GET /downloads/range/:start::end/:pkgName` for fetching package download trends. - Included sample response data for the `Trend` endpoint. --- docs/registry-api.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/registry-api.md b/docs/registry-api.md index 7deada09..91a729b8 100644 --- a/docs/registry-api.md +++ b/docs/registry-api.md @@ -8,6 +8,8 @@ * [Package](/docs/registry-api.md#package) * [User](/docs/registry-api.md#user) * [Search](/docs/registry-api.md#search) +* [Token](/docs/registry-api.md#token) +* [Trend](/docs/registry-api.md#trend) [![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/f6c8cb46358039bcd689#?env%5BRegistry%5D=W3sia2V5IjoicmVnaXN0cnkiLCJ0eXBlIjoidGV4dCIsInZhbHVlIjoiaHR0cHM6Ly9yZWdpc3RyeS5ucG0udGFvYmFvLm9yZyIsImVuYWJsZWQiOnRydWV9LHsia2V5IjoicGFja2FnZSIsInZhbHVlIjoiY25wbSIsInR5cGUiOiJ0ZXh0IiwiZW5hYmxlZCI6dHJ1ZX1d) @@ -1036,3 +1038,32 @@ GET /-/npm/v1/tokens/token/:UUID ``` #### Response 204 + +## Trend + +### get download trends for a package + +``` +GET /downloads/range/:start::end/:pkgName +``` + +#### Response 200 + +```json +HTTP/1.1 200 OK + +// /downloads/range/2024-01-01:2024-12-31/cnpmcore +{ + "downloads": [ + // ... + { "day": "2024-01-03", "downloads": 2 }, + { "day": "2024-05-30", "downloads": 16 } + ], + "versions": { + // ... + "3.61.1": [{ "day": "2024-05-30", "downloads": 5 }], + "3.61.2": [{ "day": "2024-05-30", "downloads": 5 }], + "3.61.3": [{ "day": "2024-05-30", "downloads": 6 }] + } +} +```