{"id":13834131,"url":"https://github.com/ABWalters/react-api-hooks","last_synced_at":"2025-07-10T02:30:28.165Z","repository":{"id":143904658,"uuid":"174702841","full_name":"ABWalters/react-api-hooks","owner":"ABWalters","description":"React hooks to interact with an API from a stateless component using axios.","archived":false,"fork":false,"pushed_at":"2020-09-10T18:41:54.000Z","size":4136,"stargazers_count":64,"open_issues_count":12,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-07T15:06:51.886Z","etag":null,"topics":["api","axios","hooks","react","react-hooks","reactjs","stateless-components"],"latest_commit_sha":null,"homepage":"https://react-api-hooks.abwalters.now.sh/","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/ABWalters.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-09T14:13:46.000Z","updated_at":"2024-02-27T05:03:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"911aa0eb-5e90-4567-b160-0072cf26bf51","html_url":"https://github.com/ABWalters/react-api-hooks","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/ABWalters%2Freact-api-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABWalters%2Freact-api-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABWalters%2Freact-api-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABWalters%2Freact-api-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ABWalters","download_url":"https://codeload.github.com/ABWalters/react-api-hooks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225610604,"owners_count":17496303,"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","axios","hooks","react","react-hooks","reactjs","stateless-components"],"created_at":"2024-08-04T13:00:55.227Z","updated_at":"2024-11-20T18:31:22.405Z","avatar_url":"https://github.com/ABWalters.png","language":"JavaScript","readme":"# React API Hooks\n![](https://img.shields.io/bundlephobia/minzip/react-api-hooks.svg)\n![](https://img.shields.io/github/license/abwalters/react-api-hooks.svg)\n![](https://img.shields.io/badge/React-%5E16.8.0-green.svg)\n![](https://img.shields.io/badge/axios-%5E0.17.1-green.svg)\n\nReact hooks to interact with an API from a stateless component using axios.\n\n## Features:\n - Uses axios and allows for complete request control\n - Works with stateless/functional components\n - Ability to filter and paginate API results\n - Ability to delay API calls while the user is typing\n - Works with infinite scroll components\n - Request auto-cancellation for concurrent requests or component unmount\n\n## Examples:\n- [Basic](https://react-api-hooks.abwalters.now.sh/examples/basic/)\n- [Pagination](https://react-api-hooks.abwalters.now.sh/examples/pagination/)\n- [Filtering](https://react-api-hooks.abwalters.now.sh/examples/filter/)\n- [Infinite Scroll](https://react-api-hooks.abwalters.now.sh/examples/inf-scroll/)\n\n## Installation:\n```\nnpm i react-api-hooks -s\n```\n\n## Basic Usage:\n```javascript\nimport { useAPI } from 'react-api-hooks';\n\nconst TestComponent = () =\u003e {\n  const { data=[], error, isLoading } = useAPI(url);\n  \n if (error){\n   return \u003cError /\u003e\n }\n        \n if (isLoading){\n   return \u003cLoading /\u003e\n }\n    \n  return (\n      \u003cdiv\u003e\n        {data.map(item =\u003e \u003cspan key={item.id}\u003e{item.text}\u003c/span\u003e)}\n      \u003c/div\u003e\n    )\n}\n```\n\n## Advanced Usage\n```javascript\nimport { useAPI } from 'react-api-hooks';\n\nconst TestComponent = () =\u003e {\n  const axiosConfig = {\n    method: 'POST',\n    data: { foo: 'bar' },\n    params: { id: '14' }\n  };\n  const { response, error, isLoading } = useAPI(url, axiosConfig);\n  \n if (error){\n   return \u003cError /\u003e\n }\n        \n if (isLoading){\n   return \u003cLoading /\u003e\n }\n    \n  return (\n      \u003cdiv\u003e\n        {response.data.map(item =\u003e \u003cspan key={item.id}\u003e{item.text}\u003c/span\u003e)}\n      \u003c/div\u003e\n    )\n}\n```\n\n## Reference:\n\n- [useAPI](https://react-api-hooks.abwalters.now.sh/reference/use-api/)\n- [useParams](https://react-api-hooks.abwalters.now.sh/reference/use-params/)\n- [useInfAPI](https://react-api-hooks.abwalters.now.sh/reference/use-inf-api/)\n","funding_links":[],"categories":["Packages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FABWalters%2Freact-api-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FABWalters%2Freact-api-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FABWalters%2Freact-api-hooks/lists"}