It is a bad API design to return different structure based on “external data” not passed in the request itself.
Either construct different API for logged in users and use a different end point for it, or return a “filler” when the user do not have permission to access the data.
(and it is always a bad idea to make modifications to the official rest API as you might create incompatibilities with other users of it, so at least be careful use prefixes etc)
Related Posts:
- WP REST API: check if user is logged in
- Can’t GET draft posts via REST API from headless frontend
- WP REST API – Nonce passes wp_verify_nonce even after logout
- Rest API: wp_verify_nonce() fails despite receiving correct nonce value
- Log in user using WordPress REST API
- wp_nonce vs jwt
- How to: Make JWT-authenticated requests to the WordPress API
- WordPress Rest API: How do we validate with our custom API key?
- WordPress REST API call generates nonce twice on every call
- How to Authenticate WP REST API with JWT Authentication using Fetch API
- authentication issue with rest api – rest_cannot_create
- Can I authenticate with both WooCommerce consumer key and JWT?
- How to login to WordPress site using basic authentication HTTP headers?
- Can we access the REST request parameters from within the permission_callback to enforce a 401 by returning false?
- WordPress REST API “rest_authentication_errors” doesn’t work external queries?
- Create Session with JWT
- Full page NGINX (or Cloudflare) caching and WordPress nonces
- WordPress REST API, Expired Nonce from Cache results in 403 forbidden
- Passing a borrowed nonce through Postman fails
- how to send Ajax request in wordpress backend
- permission_callback has no effect
- WP REST API GET Requests require authentication
- current_user_can(‘administrator’) returns false when I’m logged in
- Authenticating with REST API
- Make authorization mandatory on custom routes
- How to force JWT auth for default GET endpoints of WordPress rest api?
- REST API: best place to set current user for JWT auth?
- WordPress + REST API v2 and private pages Load by slug
- REST API authentication for a plugin
- PHP: authenticate for a REST request?
- Rest API basic auth not working
- Authenticate current user to REST API
- Getting 401 from ajax using an application password
- How to connect android app with WordPress website?
- WordPress REST API calls that depend on the WordPress User
- Backbone with custom rest endpoints
- WordPress HTTP API NTLM Authentication
- Advanced Access Manager: RESTful endpoint to refresh token
- Best Authetication between REST API and Mobile App
- How to verify which WordPress user requested the API in ASP .NET Core?
- Secure WordPress API, how?
- register/login api
- How can I secure my custom rest api endpoint or add under a already existing rest group
- REST API Integration without user account?
- WP REST API with Basic Auth at target website
- Cant POST with REST API on WordPress
- REST API – Authentication/Logon security
- Rest API nonce is being cached
- custom REST endpoints and application passwords
- wordpress rest api authentication failed
- How to add additional http header to a wp_error rest response
- Nonce validation in REST API
- How would I add custom tables/endpoints to the WP REST API?
- WP REST API create post authentication issue
- How to define a query parameter with REST API?
- How do I correctly setup an AJAX nonce for WordPress REST API?
- How do I use the WP REST API plugin and the OAuth Server plugin to allow for registration and login?
- Using the REST API (v2) javascript client on a private namespaced route
- Does accessing WordPress via REST API affect the site stats and analytics?
- WP API ignores filter parameter
- How to use REST API to send user metadata?
- Can the new REST API now make WP into it’s own push notification server?
- Confused about AngularJS and WordPress
- Post API tax_relation field doesn’t work
- Authentication with the Rest API when using an External Application
- No ‘Access-Control-Allow-Origin’ when call rest API
- Get subscribers via REST API and send post notification
- Calling an API to do authentication / user login
- Allow “wp-admin” edit access through headless WP web application
- WordPress REST API V2: how to get list of all posts?
- How to get data from /wp-json/wp/v2/users/me
- WordPress REST API parameters are not affecting a response
- Update meta_value in wp_postmeta using API
- WordPress plugin with CORS
- “Error: cURL error 60: SSL certificate problem: certificate has expired” when create product in WooCommerce via REST API
- How to use WordPress REST api to login a user?
- Wrong encoding of dynamic block properties problem when loggen in as editor
- Need wp rest api for featured video post
- REST api header link href
- WordPress & React Native
- update meta data (like view counter) by rest-api
- How to use WordPress rest API with Angularjs 4 [closed]
- Retrieve posts by page in wp rest api
- How to change WordPress api v2
- WP_REST_Request::get_json_params() Parsing null as Zero
- API request forbidden when requesting from same domain
- Custom WP Rest API Endpoints from JSON Schema
- Securing REST API wp-json/wp/v2/users endpoint
- Rest Api WordPress
- WordPress REST API won’t allow me to filter by author ID when called internally, works externally in Postman
- Rest API is running, but /wp-json/wp/v2/ shows only old dates
- How can I enforce user to use Application password to generate JWT token? [closed]
- Rest Api Error ‘ Error: {‘code’: ‘rest_no_route’, ‘message’: ‘No route was found matching the URL and request method.’, ‘data’: {‘status’: 404}}@ [closed]
- Restrict APP REST API for users with account and capabilities
- How to call WordPress API Internally
- Application password still works even after user is disabled / expired
- REST API Schema: how to allows for both empty string or email string
- Field fetched through REST API contains ASCII version of special characters
- Cannot create posts via REST API
- Fetch a single post from a list of posts using the REST API