{"id":19626743,"url":"https://github.com/iron-bound-designs/wp-rest-api-idempotence","last_synced_at":"2026-05-10T23:46:48.006Z","repository":{"id":80121515,"uuid":"87035041","full_name":"iron-bound-designs/wp-rest-api-idempotence","owner":"iron-bound-designs","description":"Allow WP REST API clients to specify an idempotency key for API requests.","archived":false,"fork":false,"pushed_at":"2017-04-09T05:37:15.000Z","size":111,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-09T12:43:14.725Z","etag":null,"topics":["rest-api","wordpress","wordpress-api","wordpress-plugin"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iron-bound-designs.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":"2017-04-03T03:27:56.000Z","updated_at":"2023-08-06T00:01:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"35c504a8-5f67-4d92-aacb-6078004e4497","html_url":"https://github.com/iron-bound-designs/wp-rest-api-idempotence","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/iron-bound-designs%2Fwp-rest-api-idempotence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iron-bound-designs%2Fwp-rest-api-idempotence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iron-bound-designs%2Fwp-rest-api-idempotence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iron-bound-designs%2Fwp-rest-api-idempotence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iron-bound-designs","download_url":"https://codeload.github.com/iron-bound-designs/wp-rest-api-idempotence/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240926398,"owners_count":19879737,"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":["rest-api","wordpress","wordpress-api","wordpress-plugin"],"created_at":"2024-11-11T11:47:29.577Z","updated_at":"2026-05-10T23:46:42.983Z","avatar_url":"https://github.com/iron-bound-designs.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WP API Idempotence\n\n[![Build Status](https://travis-ci.org/iron-bound-designs/wp-api-idempotence.svg?branch=master)](https://travis-ci.org/iron-bound-designs/wp-api-idempotence) ![PHP 5.4](https://img.shields.io/badge/PHP-5.4-lightgrey.svg)\n\nAllow WordPress REST API clients to specify an idempotency key for API requests. This allows for API clients to safely retry requests in case of network errors without risk of the request being processed twice.\n\n## Description\n\nWhen a network error is encountered, API clients should be able to retry a request without a risk of their request being processed twice.\nWP API Idempotence adds support for clients to include an idempotency key that uniquely identifies that request. If the server detects\nthat a request with the same key has already been processed or is currently being processed, the response for the initial request will\nbe returned.\n\nFor Example:\n\n```json\n{\n    \"title\": \"My Important Post\",\n    \"content\": \"This will only go out once!\",\n    \"status\": \"draft\",\n    \"idempotency_key\": \"1ced64e9-9537-4b7b-9919-444d9e15e201\"\n}\n```\n\n### Configuration\n* Idempotency key can either be passed in the request header or the request body.\n* The idempotency key name can be customized.\n* Change the HTTP methods the idempotency key is supported for. Defaults to `POST`, `PUT`, `PATCH`.\n\nA sample request interface is included to demonstrate the selected configuration.\n\n### Developers\n\nThe plugin includes two actions to modify the dependency injection container (DIC) and insert custom services.\n\nThe `wp_api_idempotence_initialize_container_builder` action allows you to modify the Dependency Injection builder itself and\nthe `wp_api_idempotence_initialize_container` action allows you to override dependencies. For example:\n\n```php\nadd_action( 'wp_api_idempotence_initialize_container', function( $container ) {\n    $container-\u003eset( '_dataStore', DI\\object( 'YourName\\CustomDataStore' ) );\n} );\n```\n\nUnder the hood, the plugin is made up of a `DataStore`, `RequestHasher`, `ResponseSerializer` and `RequestPoller`.\n\nThe `DataStore` is primarily responsible for retrieving or storing an idempotent request. By default, requests\nare stored in a custom database table. This could be substituted for a custom driver by implementing the `DataStore`\ninterface. For example a Redis server.\n\nThe `RequestHasher` produces a unique hash for a `WP_REST_Request` object. This hash is based off of the contents of\nthe request, not for the object via `spl_object_hash` or similar. This can also be substituted by implementing the\n`RequestHasher` interface.\n\nThe `ResponseSerializer` converts a `WP_REST_Response` or `WP_Error` object back and forth from a string representation.\nThe default JSON serializer supports filtering the serialization process using the `wp_api_idempotence_serialized_response_data`\nand `wp_api_idempotence_attach_serialized_response_data` filters. See `src/ResponseSerializer/Filtered.php`. The entire serializer can be substituted by implementing\nthe `ResponseSerializer` interface.\n\nFinally, the `RequestPoller` class polls the data store for a response if it is determined that an idempotent request\nis currently being processed when another request with the same key arrives. By default, the data store is polled\nevery seconds a maximum of 15 times to try and retrieve a response object. If no response is found, an error with code\n`rest_duplicate_idempotency_key` will be returned. This can be adjusted by overwriting the `poll.sleepSeconds` and\n`poll.maxQueries` in the DIC. The `RequestPoller` can also be entirely subsituted by implementing the `RequestPoller`\ninterface.\n\n\n## Installation\n\n1. Download the plugin from [GitHub](https://github.com/iron-bound-designs/wp-api-idempotence/archive/master.zip).\n2. Install dependencies with `composer install --no-dev`.\n3. Remove unnecessary files with `./bin/clean.sh`.\n4. Upload the plugin files to the `/wp-content/plugins/wp-api-idempotence` directory.\n5. Activate the plugin through the 'Plugins' screen in WordPress\n6. Use the Settings -\u003e WP API Idempotence screen to modify the idempotency key location or name\n7. Ensure the plugin is working by using the \"Sample Requests\" section.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firon-bound-designs%2Fwp-rest-api-idempotence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firon-bound-designs%2Fwp-rest-api-idempotence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firon-bound-designs%2Fwp-rest-api-idempotence/lists"}