{"id":25615171,"url":"https://github.com/wednesday-solutions/jsonapi-redux-data","last_synced_at":"2025-04-13T21:13:02.847Z","repository":{"id":39157731,"uuid":"231459994","full_name":"wednesday-solutions/jsonapi-redux-data","owner":"wednesday-solutions","description":"JSONAPI middleware for redux","archived":false,"fork":false,"pushed_at":"2023-01-04T14:54:22.000Z","size":8505,"stargazers_count":16,"open_issues_count":25,"forks_count":3,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-03-27T11:38:31.853Z","etag":null,"topics":["api","apisauce","axios","json-api","jsonapi","react","react-redux","redux","state-management"],"latest_commit_sha":null,"homepage":"https://wednesday.is/building-products/?utm_source=github\u0026utm_medium=jsonapi-redux-data","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/wednesday-solutions.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":"2020-01-02T21:09:37.000Z","updated_at":"2024-09-18T06:32:09.000Z","dependencies_parsed_at":"2023-02-02T16:50:13.661Z","dependency_job_id":null,"html_url":"https://github.com/wednesday-solutions/jsonapi-redux-data","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wednesday-solutions%2Fjsonapi-redux-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wednesday-solutions%2Fjsonapi-redux-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wednesday-solutions%2Fjsonapi-redux-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wednesday-solutions%2Fjsonapi-redux-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wednesday-solutions","download_url":"https://codeload.github.com/wednesday-solutions/jsonapi-redux-data/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317732,"owners_count":21083528,"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","apisauce","axios","json-api","jsonapi","react","react-redux","redux","state-management"],"created_at":"2025-02-22T03:18:46.644Z","updated_at":"2025-04-13T21:13:02.819Z","avatar_url":"https://github.com/wednesday-solutions.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JsonApi Redux Data\n\n![](jsonapi-redux-data.svg)\n\nJsonApi Redux data is a one stop shop for all your jsonapi needs!\nProvides methods to make your API call and formats and updates data in the redux store.\nIt joins all of your relations so that accessing it is as easy as _entity.relationship_\n\n**For example** if you made an API call to `base-url/tasks?include=list`, you can access your relationships as easily as **tasks[index].list**\n\n![](redux-json-api.gif)\n\n- Provides methods to make api calls to your JSONApi compliant backend and updates the redux store as well.\n\n- Combines the data so it is easily accessible\n\n- Setup in 3 easy steps\n\n## Installation\n\n```\nyarn add jsonapi-redux-data\n```\n\n**OR**\n\n```\nnpm i jsonapi-redux-data\n```\n\n## Usage\n\n- Update the reducers / rootReducers like this\n\n  ```\n  ...\n  import { jsonApiReducer } from 'jsonapi-redux-data'\n  ...\n  const rootReducer = combineReducers({\n      ...,\n      api: jsonApiReducer,\n      ...\n  })\n  ...\n\n  ```\n\n- Create the api client preferrably in the app.js\n\n  ```\n  ...\n  import { createApiClientWithTransform } from 'jsonapi-redux-data'\n  ...\n  // Create redux store with history\n  const initialState = {};\n  const store = configureStore(initialState, history);\n  ...\n\n  createApiClientWithTransform('\u003cbase-url\u003e', store)\n  ...\n  ```\n\n- Make api call easily and from anywhere\n\n  ```\n  ...\n  import { getApi } from 'jsonapi-redux-data'\n  ...\n\n  getApi({ pathname: '\u003cpathname\u003e', include: '\u003cinclude-string\u003e' })\n  ...\n  ```\n\n## Example Usage\n\n# getApi\n\n```\n  getApi({\n    pathname: 'tasks',\n    include: 'lists',\n    levelOfNesting: 3\n  });\n```\n\nInvoking this method will\n\n- make an api call to `base-url/tasks`\n- include lists in the response\n- dispatch an action of type `SUCCESS_API`\n- update the api reducer in the redux store with the formatted response.\n\n## API Documentation\n\n### getApi\n\nMake a get request and add api response to the redux store.\n\n```\n/**\n * @param  {} requestPayload: {\n *   include: object\n *   filter: object,\n *   pathname: String,\n *   levelOfNesting: number,\n *   transformList: object,\n *   id: String\n * }\n * @param {} api: Custom Api Client instead of the latest created api client\n * @param {} axios: Special axios config\n **/\nfunction getApi (requestPayload, api, axiosConfig)\n```\n\n### postApi\n\nMake a post request and add api response to the redux store\n\n```\n/**\n * @param  {} requestPayload: {\n *   include: object\n *   filter: object,\n *   pathname: String,\n *   levelOfNesting: number,\n *   transformList: object,\n *   postData: object\n *   }\n * @param {} api: Custom Api Client instead of the latest created api client\n * @param {} axios: Special axios config\n */\nfunction postApi (requestPayload, api, axiosConfig)\n```\n\n### patchApi\n\nMake a patch request and add api response to the redux store\n\n```\n/**\n *\n * @param  {} requestPayload: {\n *   include: object\n *   filter: object,\n *   pathname: String,\n *   levelOfNesting: number,\n *   transformList: object,\n *   patchData: object\n * }\n * @param {} api: Custom Api Client instead of the latest created api client\n * @param {} axios: Special axios config\n *\n * */\nfunction patchApi (requestPayload, api, axios)\n```\n\n### deleteApi\n\nMake a delete request and add api response to the redux store\n\n```\n\n/**\n *\n * @param  {} requestPayload: {\n *   pathname: String,\n *   id: String\n * }\n * @param {} api: Custom Api Client instead of the latest created api client\n * @param {} axios: Special axios config\n *\n * */\nfunction deleteApi (requestPayload, api, axios)\n```\n\n### getRequest\n\nGET HTTP REQUEST, uses the apisauce.get underneath the hood.\n\n```\n/**\n * @param  {} pathname: the endpoint path\n * @param  {} include: the jsonapi include string\n * @param  {} filter: the jsonapi filter string\n * @param  {} id: the id of the GET request.\n * @param  {} api: default is getLatestApiClient()\n * @param  {} axiosConfig: custom axiosConfig for this request\n */\nfunction getRequest (pathname, include, filter, id, api, axiosConfig)\n```\n\n### postRequest\n\nPOST HTTP REQUEST, uses the apisauce.get underneath the hood.\n\n```\n/**\n *\n * @param  {} pathname: the endpoint path\n * @param  {} include: the jsonapi include string\n * @param  {} filter: the jsonapi filter string\n * @param  {} postData: request body\n * @param  {} api: default is getLatestApiClient()\n * @param  {} axiosConfig: custom axiosConfig for this request\n */\nfunction postRequest (pathname, include, filter, postData, api, axiosConfig)\n```\n\n### patchRequest\n\nPATCH HTTP REQUEST, uses the apisauce.get underneath the hood.\n\n```\n/**\n * @param  {} pathname\n * @param  {} include: the jsonapi include string\n * @param  {} filter: the jsonapi filter string\n * @param  {} id: the id of the PATCH request.\n * @param  {} patchData: request body\n * @param  {} api: default is getLatestApiClient()\n * @param  {} axiosConfig: custom axiosConfig for this request\n */\nfunction patchRequest (pathname, include, filter, id, patchData, api,axiosConfig)\n```\n\n### deleteRequest\n\nDELETE HTTP REQUEST, uses the apisauce.get underneath the hood.\n\n```\n/**\n * @param  {} pathname\n * @param  {} id: the id of the DELETE request.\n * @param  {} api: default is getLatestApiClient()\n * @param  {} axiosConfig: custom axiosConfig for this request\n */\nfunction deleteRequest (pathname, id, api, axiosConfig)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwednesday-solutions%2Fjsonapi-redux-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwednesday-solutions%2Fjsonapi-redux-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwednesday-solutions%2Fjsonapi-redux-data/lists"}