{"id":38606217,"url":"https://github.com/itsfadnis/jsonapi-client","last_synced_at":"2026-01-17T08:38:09.376Z","repository":{"id":30720445,"uuid":"125348894","full_name":"itsfadnis/jsonapi-client","owner":"itsfadnis","description":"A convenient module to consume a jsonapi service","archived":false,"fork":false,"pushed_at":"2024-04-02T07:30:29.000Z","size":751,"stargazers_count":45,"open_issues_count":5,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-23T08:14:37.167Z","etag":null,"topics":["javascript","jsonapi","jsonapi-client","jsonapi-service","jsonapiclient"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/itsfadnis.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":"2018-03-15T10:12:54.000Z","updated_at":"2025-11-13T22:49:42.000Z","dependencies_parsed_at":"2023-01-14T17:45:23.263Z","dependency_job_id":null,"html_url":"https://github.com/itsfadnis/jsonapi-client","commit_stats":null,"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"purl":"pkg:github/itsfadnis/jsonapi-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsfadnis%2Fjsonapi-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsfadnis%2Fjsonapi-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsfadnis%2Fjsonapi-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsfadnis%2Fjsonapi-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itsfadnis","download_url":"https://codeload.github.com/itsfadnis/jsonapi-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsfadnis%2Fjsonapi-client/sbom","scorecard":{"id":497419,"data":{"date":"2025-08-11","repo":{"name":"github.com/itsfadnis/jsonapi-client","commit":"15c39a3d4afd157863f01c8c7360c9e8dac47a83"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/7 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 27 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"44 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-4w2v-q235-vp99","Warn: Project is vulnerable to: GHSA-cph5-m8f7-6c5x","Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx","Warn: Project is vulnerable to: GHSA-jr5f-v2jv-69x6","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm","Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q","Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c","Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc","Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx","Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch","Warn: Project is vulnerable to: GHSA-wpg7-2c88-r8xv","Warn: Project is vulnerable to: GHSA-pq67-2wwv-3xjx","Warn: Project is vulnerable to: GHSA-8cj5-5rvv-wf4v","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v","Warn: Project is vulnerable to: GHSA-38fc-wpqx-33j7","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T20:49:39.871Z","repository_id":30720445,"created_at":"2025-08-19T20:49:39.871Z","updated_at":"2025-08-19T20:49:39.871Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28504370,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["javascript","jsonapi","jsonapi-client","jsonapi-service","jsonapiclient"],"created_at":"2026-01-17T08:38:08.535Z","updated_at":"2026-01-17T08:38:09.351Z","avatar_url":"https://github.com/itsfadnis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://semaphoreci.com/api/v1/itsfadnis/jsonapi-client/branches/master/badge.svg)](https://semaphoreci.com/itsfadnis/jsonapi-client)\n\u003cimg alt=\"Version\" src=\"https://img.shields.io/badge/version-3.0.2-blue.svg?cacheSeconds=2592000\" /\u003e\n[![HitCount](http://hits.dwyl.io/itsfadnis/jsonapi-client.svg)](http://hits.dwyl.io/itsfadnis/jsonapi-client)\n[![Downloads](https://badgen.net/npm/dt/@itsfadnis/jsonapi-client)](https://www.npmjs.com/package/@itsfadnis/jsonapi-client)\n[![Size](https://badgen.net/bundlephobia/minzip/@itsfadnis/jsonapi-client)](https://bundlephobia.com/result?p=@itsfadnis/jsonapi-client)\n[![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/itsfadnis/jsonapi-client/blob/master/LICENSE)\n\n# jsonapi-client\nA convenient module to consume a jsonapi service\n\n## Install\n```console\n$ npm install --save @itsfadnis/jsonapi-client\n```\nor\n```console\n$ yarn add @itsfadnis/jsonapi-client\n```\n\n## Basic usage\n\n### Configure\n\nConfigure the client's http adapter. The options are as defined below:\n\n| Name                 | Description                 | Default value |\n| ---------------------|-----------------------------|---------------|\n| host (*string*)      | Server host address         | ''            |\n| namespace (*string*) | API namespace (if any)      | ''            |\n| headers (*object*)   | Request headers             | {}            |\n\n- For versions `3.0.0` \u0026 above:\n```javascript\nimport Model from '@itsfadnis/jsonapi-client';\n\nModel.configureAdapter({\n  host: 'https://example.com',\n  namespace: '/api',\n  headers: {\n    authorization: 'Basic YWxhZGRpbjpvcGVuc2VzYW1l'\n  }\n})\n```\n\n- For versions below `3.0.0`:\n```javascript\nimport { HttpAdapter, Model } from '@itsfadnis/jsonapi-client';\n\nModel.adapter = new HttpAdapter({\n  host: 'https://foo.com',\n  namespace: '/api',\n  headers: { authorization: 'Basic YWxhZGRpbjpvcGVuc2VzYW1l' },\n  // The adapter uses the Fetch API for making network requests\n  // You can pass it in as an option, else it will default to window.fetch\n  fetch: window.fetch\n});\n```\n\n### How serialization/deserialization works\n\n`@itsfadnis/jsonapi-client` internally uses [jsonapi-serializer](https://github.com/itsfadnis/jsonapi-serializer) for serializing/deserializing data to [JSON API](http://jsonapi.org/) (1.0 compliant)\n\nModels serialize themselves before making a request, and deserialize the recieved response into instances of the Model. This abstraction allows yours models to talk to a jsonapi service seamlessly without having to worry about the serialization/deserialization business.\n\nIn any case if you want finer control, it can be done by overriding some defaults.\n\nDefault serializer options are defined in the `Model#serializerOptions()` method, to override/customize them you can override this method on your model.\n\nDefault deserializer options are defined on the static property `Model.deserializerOptions`, to override/customize them you can override this property.\n\n#### Available options\n\n- [Serializer options](https://github.com/itsfadnis/jsonapi-serializer#available-serialization-option-opts-argument)\n- [Deserializer options](https://github.com/itsfadnis/jsonapi-serializer#available-deserialization-option-opts-argument)\n\n### Model definition\n\nFrom [v2.0.1](https://github.com/itsfadnis/jsonapi-client/releases/tag/v2.0.1), it is mandatory for a model to have `_type` defined as a static property.\n`Model._type` is used to describe the [type of resource objects](https://jsonapi.org/format/#document-resource-object-identification).\n\n```javascript\nclass Address extends Model {\n  static _type = 'addresses';\n\n  // Always set the base url of your resource on this property\n  static baseURL = '/addresses';\n\n  constructor(args = {}) {\n    super(args);\n    this.type = args.type;\n    this.street = args.street;\n    this.zip = args.zip;\n  }\n}\n\nclass DriversLicense extends Model {\n  static _type = 'drivers-license';\n\n  // Specify url parameters for nested resources\n  static baseURL = '/people/:person_id/drivers_license';\n\n  constructor(args = {}) {\n    super(args);\n    this.licenseNumber = args.licenseNumber;\n\n    // Drivers license belongs to person\n    this.person = this.belongsTo(Person, args.person);\n  }\n\n  // Resolve base url for nested resources in the #contructBaseURL() method\n  constructBaseURL() {\n    return this.constructor.constructBaseURL({\n      person_id: this.person.id\n    });\n  }\n}\n\nclass Person extends Model {\n  static _type = 'people';\n\n  static baseURL = '/people';\n\n  constructor(args = {}) {\n    super(args);\n    this.firstName = args.firstName || '';\n    this.lastName = args.lastName;\n\n    // Person has many addresses\n    this.addresses = this.hasMany(Address, args.addresses);\n\n    // Person has one drivers license\n    this.driversLicense = this.hasOne(DriversLicense, args.driversLicense);\n  }\n}\n```\n\n#### Standard CRUD APIs\n\n```javascript\nclass Post extends Model {\n  static _type = 'posts';\n\n  static baseURL = '/posts';\n\n  constructor(args) {\n    super(args);\n    this.title = args.title;\n    this.body = args.body;\n  }\n}\n```\n\n- Fetch posts\n```javascript\nPost.fetchAll();\n```\n\n- Fetch a single Post\n```javascript\nPost.fetch(id);\n```\n\n- Create/update post\n```javascript\n// New record (if no `id` provided)\nconst p1 = new Post({\n  title: 'foo',\n  body: 'bar'\n});\n\n// Will make a `POST` request on save\np1.save();\n\n// Treated as persisted record since `id` provided\nconst p2 = new Post({\n  id: 1,\n  title: 'boo',\n  body: 'baz'\n});\n\n// Will make a `PATCH` request on `save`\np2.save();\n```\n\n- Delete a post\n```javascript\n// Static method\nPost.destroy(id)\n\n\n// Instance method\nconst p = new Post({\n  id: 1\n});\n\np.destroy();\n```\n\n## 📝 License\n\nCopyright © 2020 [Nikhil Fadnis](https://github.com/itsfadnis).\u003cbr /\u003e\nThis project is [MIT](https://github.com/itsfadnis/jsonapi-client/blob/master/LICENSE) licensed.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsfadnis%2Fjsonapi-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitsfadnis%2Fjsonapi-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsfadnis%2Fjsonapi-client/lists"}