{"id":18251718,"url":"https://github.com/moqada/simple-api-client","last_synced_at":"2025-04-08T20:46:41.150Z","repository":{"id":57128096,"uuid":"57454145","full_name":"moqada/simple-api-client","owner":"moqada","description":"Simple API Client for JavaScript","archived":false,"fork":false,"pushed_at":"2024-04-03T23:40:44.000Z","size":440,"stargazers_count":1,"open_issues_count":22,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T07:39:26.468Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moqada.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-30T17:33:05.000Z","updated_at":"2018-04-23T08:51:47.000Z","dependencies_parsed_at":"2024-11-05T09:49:19.614Z","dependency_job_id":"ff4fad62-4e8c-421a-b69e-604c42e8c229","html_url":"https://github.com/moqada/simple-api-client","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moqada%2Fsimple-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moqada%2Fsimple-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moqada%2Fsimple-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moqada%2Fsimple-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moqada","download_url":"https://codeload.github.com/moqada/simple-api-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247927021,"owners_count":21019503,"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-11-05T09:48:19.368Z","updated_at":"2025-04-08T20:46:41.122Z","avatar_url":"https://github.com/moqada.png","language":"JavaScript","readme":"# simple-api-client\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/moqada/simple-api-client.svg)](https://greenkeeper.io/)\n\n[![NPM version][npm-image]][npm-url]\n[![Build Status][travis-image]][travis-url]\n[![Coverage Status][codecov-image]][codecov-url]\n[![Dependency Status][daviddm-image]][daviddm-url]\n[![DevDependency Status][daviddm-dev-image]][daviddm-dev-url]\n[![License][license-image]][license-url]\n\nSimple API Client for JavaScript.\n\n***WIP***\n\n## Installation\n\n```\nnpm install --save @moqada/simple-api-client\n```\n\n## Usage\n\n### JavaScript\n\n```javascript\nimport SimpleAPIClient from '@moqada/simple-api-client';\n\nclass APIClinet extends SimpleAPIClient {\n\n  constructor({token, custom}: {token: string, custom: string}) {\n    super({endpoint: 'http://api.example.com/v1'});\n    this.token = token;\n    this.custom = custom;\n  }\n\n  getDefaultOptions(): Object {\n    return {\n      headers: {\n        'Authorization': `Bearer ${this.token}`,\n        'X-Custom-Header': `${this.custom}`\n      }\n    };\n  }\n\n  toResponse(error: ?Object, response: ?Object): Object {\n    if (error) {\n      return {error};\n    }\n    return {\n      body: response.body\n    };\n  }\n\n  getUsers(query): Promise\u003c{body: Object}, {error: Object}\u003e {\n    return this.get('/users', {query});\n  }\n}\n\nconst clinet = new APIClinet({token: 'xxxxxxxyyyyy', custom: 'foobar'});\nclient.getUsers({offset: 20, limit: 10}).then(({body}) =\u003e {\n  console.log(body);\n}).catch(({error}) =\u003e {\n  console.error(error);\n}):\n```\n\n### TypeScript\n\nA import style is different from JavaScript.\n\n```typescript\nimport {SimpleAPIClient} from '@moqada/simple-api-client';\n```\n\n## Todo\n\n- [ ] Test\n- [x] Support TypeScript (experimental)\n\n## Related\n\n- [@moqada/simple-api-client-generator](https://github.com/moqada/simple-api-client-generator) - A CLI generating API Client from JSON Hyper Schema\n\n\n[npm-url]: https://www.npmjs.com/package/@moqada/simple-api-client\n[npm-image]: https://img.shields.io/npm/v/@moqada/simple-api-client.svg?style=flat-square\n[travis-url]: https://travis-ci.org/moqada/simple-api-client\n[travis-image]: https://img.shields.io/travis/moqada/simple-api-client.svg?style=flat-square\n[daviddm-url]: https://david-dm.org/moqada/simple-api-client\n[daviddm-image]: https://img.shields.io/david/moqada/simple-api-client.svg?style=flat-square\n[daviddm-dev-url]: https://david-dm.org/moqada/simple-api-client#info=devDependencies\n[daviddm-dev-image]: https://img.shields.io/david/dev/moqada/simple-api-client.svg?style=flat-square\n[codecov-url]: https://codecov.io/github/moqada/simple-api-client\n[codecov-image]: https://img.shields.io/codecov/c/github/moqada/simple-api-client.svg?style=flat-square\n[license-url]: http://opensource.org/licenses/MIT\n[license-image]: https://img.shields.io/github/license/moqada/simple-api-client?style=flat-square\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoqada%2Fsimple-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoqada%2Fsimple-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoqada%2Fsimple-api-client/lists"}