{"id":15509641,"url":"https://github.com/willin/coding-sdk","last_synced_at":"2025-04-23T02:32:25.598Z","repository":{"id":57202563,"uuid":"105083572","full_name":"willin/coding-sdk","owner":"willin","description":"Coding SDK for node.js/browser","archived":false,"fork":false,"pushed_at":"2018-04-27T07:11:48.000Z","size":89,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T16:40:16.246Z","etag":null,"topics":["api","coding","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}},"created_at":"2017-09-28T00:33:20.000Z","updated_at":"2019-03-01T08:01:33.000Z","dependencies_parsed_at":"2022-09-15T13:21:02.038Z","dependency_job_id":null,"html_url":"https://github.com/willin/coding-sdk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fcoding-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fcoding-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fcoding-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fcoding-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willin","download_url":"https://codeload.github.com/willin/coding-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250357730,"owners_count":21417342,"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","coding","sdk"],"created_at":"2024-10-02T09:43:24.471Z","updated_at":"2025-04-23T02:32:25.581Z","avatar_url":"https://github.com/willin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Coding SDK\n\n[![github](https://img.shields.io/github/followers/willin.svg?style=social\u0026label=Follow)](https://github.com/willin) [![npm](https://img.shields.io/npm/v/coding-sdk.svg)](https://npmjs.org/package/coding-sdk) [![npm](https://img.shields.io/npm/dt/coding-sdk.svg)](https://npmjs.org/package/coding-sdk) [![codecov](https://codecov.io/gh/willin/coding-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/willin/coding-sdk) [![Travis-CI](https://travis-ci.org/willin/coding-sdk.svg?branch=master)](https://travis-ci.org/willin/coding-sdk) [![codebeat badge](https://codebeat.co/badges/d5086648-bfd1-422a-a89f-d8cb76590433)](https://codebeat.co/projects/github-com-willin-coding-sdk-master)\n\n\u003e 已经疯狂得不能用代码行数（总计`56`行，包含空行和debug）来衡量该项目了，代码仅有 `1,375`字节（净化后）。\n\n五十六个民族五十六朵花。啦啦啦~\n\n[TOC]\n\n## 安装\n\n```bash\nyarn add coding-sdk\n# or npm i -S coding-sdk\n```\n\n本项目中使用 `camelCase` 驼峰命名法则。\n\n\n## Scope 说明\n\nscope 参数应传入数组如： `['user', 'project', 'team']`\n\nscope 名称 | 说明 | 授权\n:--| -- | :--:\nuser | 授权获取用户信息（用户名称，头像，tag，email，动态 ） | 读\nuser:email | 授权获取用户的email ） | 读\nnotification | 授权读取通知信息，包含email通知 | 读写\nsocial | 授权读取冒泡列表，好友列表 | 读\nsocial:tweet | 授权发送冒泡，冒泡操作（点赞、评论、删除） | 读写\nsocial:message | 授权读取、发送私信、私信语音 | 读写\nproject | 授权项目信息、项目列表，仓库信息，公钥列表、成员，任务列表 | 读\nproject:members | 授权项目管理者增、删、改项目成员，退出项目 | 读写\nproject:task | 授权任务操作，包含增、删、改 | 读写\nproject:file | 授权文件，包含增、删、改 | 读写\nproject:depot | 获取 commit 信息，分支操作，MR/PR, LineNotes, fork, webhook 等操作 | 读写\nproject:key | 授权操作部署公钥、个人公钥 | 读写\nteam | 获取团队相关基本信息 | 读\n\n## Oauth 使用 示例\n\n```js\nconst SDK = require('coding-sdk');\n// 初始化实例：\nconst coding = new SDK({\n  clientId: 'xxx',\n  clientSecret: 'xxx',\n  callback: 'http://localhost/coding/callback'\n});\n\n// 获取 OAuth 鉴权链接 URL\nconsole.log(coding.url());\n// 如： https://coding.net/oauth_authorize.html?client_id=xxx\u0026redirect_uri=xxx\u0026response_type=code\u0026scope=user\n// 登录后跳转回 callback URL，获取其中的 code 字段\n\n// 注意包裹在 async 内， 或者用 Promise.then(res=\u003e{ console.log(res.data) }) 来获取返回 json 结果\nconst { data } = await coding.get('oauth/access_token', {\n  grant_type: 'authorization_code',\n  code: 'xxxxxx'\n});\n/*\n{ access_token: 'xxxxx',\n  refresh_token: 'xxxxx',\n  expires_in: '864000' }\n*/\n```\n\n## Token 使用 示例\n\n```js\nconst coding = new SDK({\n  user: 'willin',\n  token: 'xxxxxx'\n});\n\nconst { data } = await coding.delete('user/XXX/project/XXX/task/XXX');\n/*\n{ code: 0, data: true }\n*/\n```\n\n## 一些公开接口 使用 示例\n\n```js\nconst coding = new SDK();\n\nconst { data } = await coding.get('user/key/willin')\n/*\n{\n  code: 0,\n  data: { ... }\n}\n*/\n```\n\n## 补充示例\n\n### 获取 OAuth 登录地址\n\n```js\ncoding.url();\n```\n\n### 获取 access_token\n\n```js\nconst data = await coding.get('oauth/access_token', {\n  grantType: 'authorization_code',\n  code: 'xxxxxx'\n}).then(res=\u003eres.data);\n/*\n返回数据格式:\n{\n  access_token: \"xxxxxxx\",\n  refresh_token: \"xxxxxx\",\n  expires_in: \"86382817\"\n}\n*/\n```\n\n## License\n\nApache 2.0\n\n通过支付宝捐赠：\n\n![qr](https://cloud.githubusercontent.com/assets/1890238/15489630/fccbb9cc-2193-11e6-9fed-b93c59d6ef37.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillin%2Fcoding-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillin%2Fcoding-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillin%2Fcoding-sdk/lists"}