{"id":23436988,"url":"https://github.com/amplication/ra-data-rest-amplication","last_synced_at":"2025-10-06T10:47:55.619Z","repository":{"id":252530398,"uuid":"840708379","full_name":"amplication/ra-data-rest-amplication","owner":"amplication","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-10T16:04:52.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-04T02:00:17.666Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amplication.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":"2024-08-10T12:50:37.000Z","updated_at":"2024-08-10T16:04:55.000Z","dependencies_parsed_at":"2024-08-10T14:29:37.289Z","dependency_job_id":"19007109-db19-48fe-b87d-4213a6bd1eb0","html_url":"https://github.com/amplication/ra-data-rest-amplication","commit_stats":null,"previous_names":["amplication/ra-data-rest-amplication"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/amplication/ra-data-rest-amplication","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amplication%2Fra-data-rest-amplication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amplication%2Fra-data-rest-amplication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amplication%2Fra-data-rest-amplication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amplication%2Fra-data-rest-amplication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amplication","download_url":"https://codeload.github.com/amplication/ra-data-rest-amplication/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amplication%2Fra-data-rest-amplication/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278598575,"owners_count":26013289,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-12-23T13:36:16.473Z","updated_at":"2025-10-06T10:47:55.602Z","avatar_url":"https://github.com/amplication.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Amplication REST Data Provider For React-Admin\n\nA REST API data provider for [react-admin](https://github.com/marmelab/react-admin/)\nbuilt for REST API generated with [Amplication](https://amplication.com)\n\n## Installation\n\n```sh\nnpm install --save ra-data-rest-amplication\n```\n\n## Usage\n\nCreate a Data Provider by calling the `amplicationRestProvider` function with the API URL as first argument. Then pass this Data Provider to the `\u003cAdmin\u003e` component.\n\n```jsx\n// in src/App.js\nimport * as React from \"react\";\nimport { Admin, Resource } from \"react-admin\";\nimport amplicationRestProvider from \"ra-data-rest-amplication\";\n\nimport { PostList } from \"./posts\";\n\nconst App = () =\u003e (\n  \u003cAdmin dataProvider={simpleRestProvider(\"http://my.api.url/\")}\u003e\n    \u003cResource name=\"posts\" list={PostList} /\u003e\n  \u003c/Admin\u003e\n);\n\nexport default App;\n```\n\nThe `amplicationRestProvider` function accepts a second parameter, which is an HTTP client function. By default, it uses react-admin's [`fetchUtils.fetchJson()`](https://marmelab.com/react-admin/fetchJson.html) as HTTP client. It's similar to HTML5 `fetch()`, except it handles JSON decoding and HTTP error codes automatically.\n\nYou can wrap this call in your own function to [add custom headers](#adding-custom-headers), for instance to set an `Authorization` bearer token:\n\n```jsx\nimport { fetchUtils, Admin, Resource } from \"react-admin\";\nimport amplicationRestProvider from \"ra-data-rest-amplication\";\n\nconst httpClient = (url, options = {}) =\u003e {\n  if (!options.headers) {\n    options.headers = new Headers({ Accept: \"application/json\" });\n  }\n  const { token } = JSON.parse(localStorage.getItem(\"auth\"));\n  options.headers.set(\"Authorization\", `Bearer ${token}`);\n  return fetchUtils.fetchJson(url, options);\n};\nconst dataProvider = amplicationRestProvider(\n  \"http://localhost:3000\",\n  httpClient\n);\n\nconst App = () =\u003e (\n  \u003cAdmin dataProvider={dataProvider} authProvider={authProvider}\u003e\n    ...\n  \u003c/Admin\u003e\n);\n```\n\n## REST Dialect\n\nThis Data Provider fits REST APIs using simple GET parameters for filters and sorting. This is the dialect used for instance in [FakeRest](https://github.com/marmelab/FakeRest).\n\nThe `ra-data-rest-amplication` providers works against a REST server that was generated with Amplication, or respects its grammar.\n\n## Adding Custom Headers\n\nThe provider function accepts an HTTP client function as second argument. By default, they use react-admin's `fetchUtils.fetchJson()` as HTTP client. It's similar to HTML5 `fetch()`, except it handles JSON decoding and HTTP error codes automatically.\n\nThat means that if you need to add custom headers to your requests, you just need to _wrap_ the `fetchJson()` call inside your own function:\n\n```jsx\nimport { fetchUtils, Admin, Resource } from \"react-admin\";\nimport amplicationRestProvider from \"ra-data-rest-amplication\";\n\nconst httpClient = (url, options = {}) =\u003e {\n  if (!options.headers) {\n    options.headers = new Headers({ Accept: \"application/json\" });\n  }\n  // add your own headers here\n  options.headers.set(\"X-Custom-Header\", \"foobar\");\n  return fetchUtils.fetchJson(url, options);\n};\nconst dataProvider = amplicationRestProvider(\n  \"http://localhost:3000\",\n  httpClient\n);\n\nrender(\n  \u003cAdmin dataProvider={dataProvider} title=\"Example Admin\"\u003e\n    ...\n  \u003c/Admin\u003e,\n  document.getElementById(\"root\")\n);\n```\n\nNow all the requests to the REST API will contain the `X-Custom-Header: foobar` header.\n\n## Enabling Query Cancellation\n\nTo enable query cancellation, you need to set the `supportAbortSignal` property of the data provider to `true`. This will allow react-admin to cancel queries when the user navigates away from a view before the query is completed.\n\n```tsx\nconst dataProvider = amplicationRestProvider(\"https://myapi.com\");\ndataProvider.supportAbortSignal = true;\n```\n\n## License\n\nThis data provider is licensed under the MIT License, and sponsored by [amplication](https://amplication.com).\n\n## Credits\n\nThis provider was built on top of the source code of `ra-data-simple-rest`\n\nhttps://github.com/marmelab/react-admin/tree/master/packages/ra-data-simple-rest\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famplication%2Fra-data-rest-amplication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famplication%2Fra-data-rest-amplication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famplication%2Fra-data-rest-amplication/lists"}