I've enabled the JSON:API Views module to expose View data via the JSON:API. I've created a page view of Visitors data. Preview data suggests that there is data available. The view is set to be exposed via JSON:API. However, navigating to the jsonapi path (/jsonapi/views/visitors/page_1) consistently results in a 404 "Page Not Found" error.

Other views of different data types are exposed via the JSON:API just fine.

Why would Visitors info not be accessible via the JSON:API?

  • First check the access permissions. Does the user accessing JSON:API have permission to view the data? Commented Nov 4, 2023 at 5:04
  • For testing purposes, I'm setting the View to be unauthenticated, and am still not seeing any data come through.
    – Kyle
    Commented Nov 6, 2023 at 17:27
  • The permissions on the view are relevant, but also the permissions on the visitor entities are relevant. The anonymous user must have read access to visitors entities (not just the view) or nothing will be shown. JSON:API will always check the permissions of the entity before returning it. Commented Nov 7, 2023 at 14:52

1 Answer 1


Follow these steps to expose visitor data by json API:

Create view of "vistior" entity type of rest export

Then add required path/url like: jsonapi/views/visitors in path setting

Select "json" format by click on setting link > that next to serializer format

you can select field or entity as per requirement

In the access you can select any option as per requirement or can keep unrestricted as well (testing purpose)

Save the view & try to hit the view page, result 'll start appear

Note:There is no need to configure any additional permission.

if you try to check in this file here is routes() function Try to get entity_type value it is empty due to which code return & getting 404 page not found error. so JSON:API Views" module not support/extend to "visitor" module functionality

There are some approaches that you can follow:

  • either extend "json api view" module functionality so that it supports vistor entity it requires custom workaround

  • create custom json api which is also custom workaround

  • Create REST export view as mentioned in answer

  • Thanks @mini, this method of exposing the data via REST export allows me to expose the data in a consumable JSON format. So for that, it meets my needs. The data still will not show via the JSON:API route though, and I am interested if anyone has a solution in that regard. But I will accept this answer if nothing else comes through!
    – Kyle
    Commented Nov 6, 2023 at 17:26
  • I have checked with JSON:API Views as well same error replicate : Page not found But for this reason of this issue: "JSON:API Views" module not support/extend to "visitor" module functionality & if you check at code level "visitor" is separate custom entity not drupal standard entity Commented Nov 6, 2023 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.