{"id":15046229,"url":"https://github.com/willin/wrescuetime","last_synced_at":"2025-10-26T13:31:02.816Z","repository":{"id":17561927,"uuid":"82243981","full_name":"willin/wrescuetime","owner":"willin","description":"一个10行代码的 Rescuetime Open API SDK","archived":false,"fork":false,"pushed_at":"2023-07-12T00:02:45.000Z","size":330,"stargazers_count":8,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-14T04:55:54.442Z","etag":null,"topics":["api","diy","efficiency","nodejs","rescuetime","sdk"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"willin","custom":"https://afdian.net/@willin"}},"created_at":"2017-02-17T01:33:25.000Z","updated_at":"2023-08-22T09:06:10.000Z","dependencies_parsed_at":"2022-08-07T08:16:05.330Z","dependency_job_id":null,"html_url":"https://github.com/willin/wrescuetime","commit_stats":{"total_commits":21,"total_committers":2,"mean_commits":10.5,"dds":0.4285714285714286,"last_synced_commit":"0645dfa8e67dc95805b2ef798255865c4722d36a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fwrescuetime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fwrescuetime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fwrescuetime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fwrescuetime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willin","download_url":"https://codeload.github.com/willin/wrescuetime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219862887,"owners_count":16555951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","diy","efficiency","nodejs","rescuetime","sdk"],"created_at":"2024-09-24T20:52:53.107Z","updated_at":"2025-10-26T13:31:02.439Z","avatar_url":"https://github.com/willin.png","language":"JavaScript","funding_links":["https://github.com/sponsors/willin","https://afdian.net/@willin"],"categories":[],"sub_categories":[],"readme":"# WRescuetime\n\n[![github](https://img.shields.io/github/followers/willin.svg?style=social\u0026label=Followers)](https://github.com/willin)  [![npm](https://img.shields.io/npm/v/wrescuetime.svg)](https://npmjs.org/package/wrescuetime) [![npm](https://img.shields.io/npm/dm/wrescuetime.svg)](https://npmjs.org/package/wrescuetime) [![npm](https://img.shields.io/npm/dt/wrescuetime.svg)](https://npmjs.org/package/wrescuetime) [![codebeat badge](https://codebeat.co/badges/0d123239-5db0-439c-b40f-c0a23ea73194)](https://codebeat.co/projects/github-com-willin-wrescuetime-master)\n\n## 介绍\n\n[RescueTime](https://www.rescuetime.com/ref/1496575) 是一个效率分析的软件，它可以全天候记录你的在线操作，并进行效率分析。\n\n配合`Gyroscope`（iOS APP）、`IFTTT`等使用有奇效。并且可以自行 DIY新的玩法。\n\n## 安装和使用\n\n国际惯例：\n\n```bash\nyarn add wrescuetime\n# 或\nnpm install wrescuetime --save\n```\n\n使用示例：\n\n```js\nconst Wr = require('wrescuetime');\nconst wr = WR('full_key');\n\n// Analytic Data\nwr.analyticData({\n  rs: 'minute',\n  pv: 'interval',\n  rk: 'efficiency'\n}).then((d) =\u003e {\n  console.log(d);\n});\n```\n\n支持方法：\n\n- analyticData\n- dailySummaryFeed\n- alertsFeed\n- highlightsFeed\n- highlightsPost\n\nAPI 文档参考： https://www.rescuetime.com/anapi/setup/documentation\n\n### 分步教程\n\n#### 1.注册安装 RescueTime\n\n注册链接： [https://www.rescuetime.com/](https://www.rescuetime.com/ref/1496575)\n\n下载并安装客户端，支持的环境有：\n\n* Mac OS X: 10.6以上\n* Windows: XP/Vista/7/8/10\n* Linux: Ubuntu/Fedora\n* Android: 2.1以上（需要 Google Play）\n* Chrome 插件\n* Firefox 插件\n\n安装完成后，通过 [API \u0026 Integrations](https://www.rescuetime.com/anapi/setup/overview) 链接新建 API Key。\n\n#### 2. 搭建测试环境\n\n\n服务器代码(使用`koa@next`、`koa-route@next`和`moment`实现)：\n\n```js\nconst Wr = require('wrescuetime');\nconst moment = require('moment');\nconst Koa = require('koa');\nconst route = require('koa-route');\nconst redisClient = require('wulian-redis');\n\nconst wr = Wr('输入你的 Key');\nmoment.locale('zh-CN');\nconst redis = redisClient();\n\nconst app = new Koa();\n\n// 核心代码\n// JSON 格式输出\napp.use(route.get('/', async (ctx) =\u003e {\n  let data = await redis.get('rescuetime');\n  if (data === null) {\n    data = await wr.analyticData({\n      rs: 'minute',\n      pv: 'interval',\n      rk: 'efficiency'\n    });\n    await redis.setex('rescuetime', 60, JSON.stringify(data));\n  } else {\n    data = JSON.parse(data);\n  }\n  const row = data.rows[data.rows.length - 1];\n  const time = Math.abs(moment(row[0]).diff()) / 60000;\n  const efficiency = parseFloat(row[4]);\n  ctx.body = {\n    status: 1,\n    time,\n    efficiency,\n    date: row[0]\n  };\n}));\n\n// 图片链接跳转\napp.use(route.get('/icon', async (ctx) =\u003e {\n  let data = await redis.get('rescuetime');\n  if (data === null) {\n    data = await wr.analyticData({\n      rs: 'minute',\n      pv: 'interval',\n      rk: 'efficiency'\n    });\n    await redis.setex('rescuetime', 60, JSON.stringify(data));\n  } else {\n    data = JSON.parse(data);\n  }\n  const row = data.rows[data.rows.length - 1];\n  const time = Math.abs(moment(row[0]).diff()) / 60000;\n  const efficiency = parseFloat(row[4]);\n\n  if (time \u003e 60) {\n    ctx.redirect('http://example.com/offline.png');\n  } else {\n    if (efficiency \u003e 90) {\n      ctx.redirect('http://example.com/busy.png');\n    }\n    else {\n      ctx.redirect('http://example.com/online.png');\n    }\n  }\n}));\n\napp.listen(3000);\n```\n\n说明：\n\n* 时间差（分钟）大于60判断为离线\n* 效率大于90%判断为忙碌，请勿打扰\n* 其他在线状况则显示默认在线\n\n## 相关项目推荐\n\n- 该SDK实际项目示例： https://github.com/willin/up.js.cool\n- 微信小程序SDK： https://github.com/willin/mp-sdk\n- 阿里云SDK： https://github.com/willin/waliyun\n- 腾讯云SDK： https://github.com/willin/wqcloud\n- 网易云音乐SDK： https://github.com/willin/wnm\n\n## License\n\nApache 2.0\n\n\u003cimg width=\"483\" alt=\"donate\" src=\"https://user-images.githubusercontent.com/1890238/59274374-cd594300-8c8c-11e9-8ee8-fe9be4b49cdb.png\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillin%2Fwrescuetime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillin%2Fwrescuetime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillin%2Fwrescuetime/lists"}