{"id":22245926,"url":"https://github.com/integritystl/integrityxd-wp-rest-api-client","last_synced_at":"2026-04-16T13:32:42.640Z","repository":{"id":253146672,"uuid":"842610500","full_name":"integritystl/integrityxd-wp-rest-api-client","owner":"integritystl","description":"A low-level npm package for WordPress REST API requests","archived":false,"fork":false,"pushed_at":"2025-01-24T12:55:25.000Z","size":709,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"dev","last_synced_at":"2025-01-30T10:25:29.111Z","etag":null,"topics":["internal","javascript","rest-api","wordpress"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/integritystl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-14T17:43:44.000Z","updated_at":"2025-01-10T21:35:41.000Z","dependencies_parsed_at":"2024-11-15T17:32:34.878Z","dependency_job_id":"02d725fd-fe20-4600-8d5c-8b8b7e8a11d3","html_url":"https://github.com/integritystl/integrityxd-wp-rest-api-client","commit_stats":null,"previous_names":["integritystl/integrityxd-wp-rest-api-client"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/integritystl%2Fintegrityxd-wp-rest-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/integritystl%2Fintegrityxd-wp-rest-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/integritystl%2Fintegrityxd-wp-rest-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/integritystl%2Fintegrityxd-wp-rest-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/integritystl","download_url":"https://codeload.github.com/integritystl/integrityxd-wp-rest-api-client/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245449779,"owners_count":20617208,"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":["internal","javascript","rest-api","wordpress"],"created_at":"2024-12-03T05:19:54.481Z","updated_at":"2026-04-16T13:32:42.570Z","avatar_url":"https://github.com/integritystl.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @integrityxd/wp-rest-api-client\n\nThis package provides a typed, low-level interface for interacting with the WordPress REST API using a functional approach. It uses Axios for making HTTP requests.\n\n## Installation\n\n```bash\nnpm install @integrityxd/wp-rest-api-client axios\n```\n\n## Usage\n\nImport the necessary functions and types:\n\n```typescript\nimport axios from 'axios';\nimport { createWordPressAPI } from 'wordpress-rest-api';\n```\n\nCreate an Axios instance and initialize the API:\n\n```typescript\nconst axiosInstance = axios.create({\n  baseURL: 'https://your-wordpress-site.com/wp-json/wp/v2',\n  headers: {\n    'Content-Type': 'application/json',\n    'Authorization': 'Bearer YOUR_AUTH_TOKEN'\n  }\n});\n\nconst wpApi = createWordPressAPI(axiosInstance);\n```\n\nUse the API methods:\n\n```typescript\n// Fetch all posts\nconst posts = await wpApi.fetchAllItems('/posts');\n\n// Insert a new post\nconst newPost = await wpApi.insertItem('/posts', { \n  title: 'New Post', \n  content: 'Post content', \n  status: 'publish' \n});\n\n// Update a post\nconst updatedPost = await wpApi.updateItem(`/posts/${newPost.data.id}`, { \n  title: 'Updated Post Title' \n});\n\n// Delete a post\nawait wpApi.deleteItem(`/posts/${newPost.data.id}`);\n```\n\n## API Methods\n\n- `insertItem(url: string, data: WordPressItem): Promise\u003cAxiosResponse\u003cWordPressItem\u003e\u003e`\n- `deleteItem(url: string): Promise\u003cAxiosResponse\u003c{ deleted: boolean }\u003e\u003e`\n- `forceDeleteItem(url: string): Promise\u003cAxiosResponse\u003c{ deleted: boolean }\u003e\u003e`\n- `updateItem(url: string, data: WordPressItem): Promise\u003cAxiosResponse\u003cWordPressItem\u003e\u003e`\n- `updateItemBuffer(url: string, data: Buffer, filename: string): Promise\u003cAxiosResponse\u003cWordPressItem\u003e\u003e`\n- `fetchAllItems(url: string, extraParams?: Record\u003cstring, unknown\u003e): Promise\u003cWordPressItem[]\u003e`\n\nAll methods use the provided Axios instance for making requests.\n\n## Types\n\n```typescript\ninterface WordPressItem {\n  [key: string]: unknown;\n}\n```\n\n## Customizing Axios Instance\n\nYou can customize the Axios instance before passing it to `createWordPressAPI`. This allows you to:\n\n- Set custom headers\n- Configure request timeouts\n- Add request or response interceptors\n- Set up custom authentication\n\nExample of a custom Axios instance:\n\n```typescript\nconst axiosInstance = axios.create({\n  baseURL: 'https://your-wordpress-site.com/wp-json/wp/v2',\n  timeout: 10000,\n  headers: {'X-Custom-Header': 'foobar'}\n});\n\naxiosInstance.interceptors.request.use((config) =\u003e {\n  // Modify config before request is sent\n  return config;\n});\n\nconst wpApi = createWordPressAPI(axiosInstance);\n```\n\nFor more detailed documentation on Axios configuration, please refer to the [Axios documentation](https://axios-http.com/docs/config_defaults).\n\n## Development\n\nTo set up the development environment:\n\n1. Clone the repository\n2. Run `npm install`\n3. Run `npm run test` to run the test suite\n4. Run `npm run lint` to lint the code\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintegritystl%2Fintegrityxd-wp-rest-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintegritystl%2Fintegrityxd-wp-rest-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintegritystl%2Fintegrityxd-wp-rest-api-client/lists"}