There’s actually a hook that will fire for all REST API requests. It’s the recommended hook to use when adding your own API endpoints, so you can be sure that this hook will be fired for every single REST API request that your website handles.
/**
* @param \WP_REST_Server $wp_rest_server
*/
function capture_all_rest_api_requests( $wp_rest_server ) {
// Your code here to do your custom REST API handling.
}
add_action( 'rest_api_init', 'capture_all_rest_api_requests' );
Unfortunately you haven’t provided further details as to what exactly you want to do or achieve with this hook, so we can’t be sure this is the most appropriate hook to use.
But you asked for a hook for all incoming requests for the REST API, and this is it.
When this hook is fired, you’ll know it’s a REST API request and nothing else.
Related Posts:
- x-wp-nonce is not allowed by Access-Control-Allow-Headers in preflight response
- WordPress REST API “rest_authentication_errors” doesn’t work external queries?
- Passing a borrowed nonce through Postman fails
- How send get request to external api with username and password
- WP_REMOTE_POST Requests are being blocked by API provider [closed]
- Get all PDF files from page with WordPress API
- “No Access-Control-Allow-Origin header is present” even though it is in the entry file
- Validate rest-api call on create
- Get a remote post ID via API given URL
- How to change the date and time in REST API for comments?
- WordPress HTTP API NTLM Authentication
- [Zapier + WP Webhooks Pro]: Custom Fields get cut off at first comma or semicolon
- REST API and filtering by meta value
- Rest API: trouble receiving response through script (browser and Postman display correctly)
- Is there a way I can fetch the WordPress Developer Code References with an API?
- How to display relations via wordpress Rest API
- How to add Relations of a CCT from JetEngine via WordPress Rest API
- Can I overwrite default WordPress Json API For no more pages text
- Secure WordPress API, how?
- register/login api
- WordPress REST API in Integromat: How to overcome “Sorry, you are not allowed to list users / edit this…”
- how to create JSON array [] for REST response?
- Remove unwanted fields from WP API response
- How to receive JSON payload from a digital device
- The REST API encountered an error in wordpress?
- WordPress API “code”:”rest_no_route” with Custom Route
- Connecting WordPress with an External API
- WordPress single page website redirect to index.html
- Autotrader API Integration
- REST API get featured image source for custom post type
- Update post / page using API + python
- JS WordPress API fetch no response headers
- Issue with API after 6.2 update
- Woocommerce API for calling products by Category ID
- Fetch All Posts (Including Those Using a Custom Post Type) With WordPress API
- How to use _embed when using _fields?
- Filter posts by multiple custom taxonomy terms using AND operator in REST API v2 (WordPress)
- WP REST API core major changes
- How to get all posts from parent and children categories?
- Attach featured image to custom endpoints
- WordPress: How to create custom REST API route?
- get_userdata by username
- REST API URL parameters not working with apache server
- How to Pull ALL Posts, Categories, or Tags in WordPress REST API
- Query the REST API for a Tag by slug
- Rest API Custom Endpoint with space character
- apiFetch security
- Application Password is not enable by default?
- Cannot get ‘sanitize_callback’ to work for rest parameters
- How to use current_user_can() in register_rest_route()?
- WP REST API GET Requests require authentication
- How do I get the intended post type of a revision post?
- What’s the “?P” register rest api construct, what is for and where to find official docs?
- WordPress REST API json – How to activate gzip compression?
- Does it still make sense using json endpoint ep_mask now that there’s the new rest api? [closed]
- Erratic OAuth 1.0 Signature Mismatch Errors
- WordPress custom endpoint returning blank response
- How to force JWT auth for default GET endpoints of WordPress rest api?
- REST API: best place to set current user for JWT auth?
- Limit post creation by role
- Adding Images into API
- How do I query my WordPress posts on another HTML page using the WordPress Restful API?
- WP_REST_Response() doesn’t seem to return the expected object
- Setting ?context=edit results in rest_forbidden_context, even for an Administrator user
- wc_get_products() not return the images details
- WordPress REST Api: update user
- WP Rest Api- Update callback (POST request) to existing database table through the rest api
- Save default options as an array of options and display in REST API
- Woocommerce REST API – add filter to set maximum query per page for product brands [closed]
- WordPress REST Api get posts by ID
- Which route in the WP REST API do I access data passed into register_setting()?
- Images are displaying as blank images
- How to use Python to create a Post in WordPress?
- Send a get request to wordpress
- Best Authetication between REST API and Mobile App
- Replace content via rest api only?
- WP rest api endpoint protection using jwt token
- WP Rest API – Change response status code for failed validation request
- Unable to create a Rest end-point
- Log in user using WordPress REST API
- Can i fetch the list of pouplar posts of last 24 hours from WordPress API?
- Escape commas in REST API
- is it possible to fetch data from a remote api while admin is writing a new post?
- Loop through WordPress API response errors
- rest api add post meta
- phpmailer_init ignored on REST calls
- Periodically Query an external API on wordpress site
- Extending the API I created to return category names
- order by meta start_dato value (ACF)
- Display Post Featured Image along with Categories via WP Rest API
- Register rest field authentication with REST API
- wp rest api (v2) filter not working (404 error – rest_no_route)
- Bypass wp_safe_remote_get()?
- Handling _embed for custom REST API endpoints
- Restructure Objects coming from Rest-Api
- WooCommerce REST API endpoints don’t exist
- Script tag in string in wordpress rest api body to create post
- Customizer Changeset, Sidebar and Rest API Custom Endpoints
- Auto generating API keys using the Application Authentication Endpoint [closed]
- Uploading media to wordpress API with C# HttpClient