{"id":15509769,"url":"https://github.com/willin/afdian-sdk","last_synced_at":"2025-04-23T02:53:24.110Z","repository":{"id":45394821,"uuid":"436463791","full_name":"willin/afdian-sdk","owner":"willin","description":"爱发电 SDK for Node.js \u0026 Browser","archived":false,"fork":false,"pushed_at":"2023-11-13T13:17:24.000Z","size":231,"stargazers_count":7,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T17:41:55.833Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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":"CHANGELOG.md","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":"2021-12-09T02:57:55.000Z","updated_at":"2025-02-26T08:07:36.000Z","dependencies_parsed_at":"2023-11-17T23:09:01.352Z","dependency_job_id":"b1672d40-a17c-4e20-a410-e5852259e38a","html_url":"https://github.com/willin/afdian-sdk","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":0.4444444444444444,"last_synced_commit":"58bb8f73753fccc5672a8068112e814967de274c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fafdian-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fafdian-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fafdian-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fafdian-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willin","download_url":"https://codeload.github.com/willin/afdian-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248997453,"owners_count":21195879,"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":[],"created_at":"2024-10-02T09:43:49.445Z","updated_at":"2025-04-23T02:53:24.088Z","avatar_url":"https://github.com/willin.png","language":"TypeScript","funding_links":["https://github.com/sponsors/willin","https://afdian.net/@willin"],"categories":[],"sub_categories":[],"readme":"# afdian - 爱发电 SDK for Node.js \u0026 Browser\n\n[![GitHub followers](https://img.shields.io/github/followers/willin?logo=github\u0026style=flat-square\u0026label=)](https://github.com/willin) [![npm](https://img.shields.io/npm/v/afdian?style=flat-square\u0026logo=npm)](https://npmjs.org/package/afdian) [![npm](https://img.shields.io/npm/dm/afdian?style=flat-square\u0026label=down)](https://npmjs.org/package/afdian) [![npm](https://img.shields.io/npm/dt/afdian?style=flat-square\u0026label=down)](https://npmjs.org/package/v0) [![Travis (.com)](https://img.shields.io/travis/com/willin/afdian-sdk?style=flat-square\u0026logo=travis\u0026label=ci)](https://app.travis-ci.com/willin/afdian-sdk) [![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/willin/afdian-sdk?style=flat-square\u0026logo=codeclimate\u0026label=rank)](https://codeclimate.com/github/willin/afdian-sdk/maintainability) [![Code Climate coverage](https://img.shields.io/codeclimate/coverage/willin/afdian-sdk?style=flat-square\u0026label=cov)](https://codeclimate.com/github/willin/afdian-sdk/test_coverage)\n\n## 使用 Usage\n\n### 安装 Install\n\n```bash\nyarn add afdian\n# or\nnpm install --save afdian\n```\n\n### 引入 Import\n\n```js\nimport Afdian, { AfdianClientOptions, AfdianSponsorResponse, AfdianOrderResponse } from 'afdian';\n// 其中 { } 中 ts 类型可以不导入\n// Types in { } block can be ignored\n\nconst afdian = new Afdian({\n  userId: 'xxxx',\n  token: 'xxxx'\n});\n// Ref: https://afdian.net/dashboard/dev\n\nconst res = await afdian.ping();\n// {\n//   ec: 200,\n//   em: 'pong',\n//   data: { }\n// }\n\n// 查询订单\nconst res = await afdian.queryOrder(1);\n// {\n//   ec: 200,\n//   em: 'order',\n//   data: {\n//     list: [],\n//     total_count: 0,\n//     total_page: 0\n//   }\n// }\n\n// 查询赞助者\nconst res = await afdian.querySponsor(1);\n// {\n//   ec: 200,\n//   em: 'sponsor',\n//   data: {\n//     list: [],\n//     total_count: 0,\n//     total_page: 0\n//   }\n// }\n\n// 订单 Webhook 回调\nconst res = await afdian.webhookOrder(context);\n// {\n//   \"ec\": 200,\n//   \"em\": \"ok\",\n//   \"data\": {\n//     \"type\": \"order\",\n//     \"order\": {\n//       \"out_trade_no\": \"202106232138371083454010626\",\n//       \"user_id\": \"adf397fe8374811eaacee52540025c377\",\n//       \"plan_id\": \"a45353328af911eb973052540025c377\",\n//       \"month\": 1,\n//       \"total_amount\": \"5.00\",\n//       \"show_amount\": \"5.00\",\n//       \"status\": 2,\n//       \"remark\": \"\",\n//       \"redeem_id\": \"\",\n//       \"product_type\": 0,\n//       \"discount\": \"0.00\",\n//       \"sku_detail\": [],\n//       \"address_person\": \"\",\n//       \"address_phone\": \"\",\n//       \"address_address\": \"\"\n//     }\n//   }\n// }\n```\n\n## License\n\nApache 2.0\n\n捐赠 / Donate: \u003chttps://afdian.net/@willin\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillin%2Fafdian-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillin%2Fafdian-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillin%2Fafdian-sdk/lists"}