Hi, i would like to know how to retrive the rest api url for views/blocks
I can't find any documentation
Hello, we don't have any documentation available for working with Views in the REST API because the REST API is not fully, officially, supported in Toolset. With that being said, you could set up your own custom endpoint and use the PHP Views APIs render_view, render_view_template, get_view_query_results, etc. to produce your own custom solution. It depends on what you want to accomplish with the REST API. This ticket includes an example of rendering a post with a specific Content Template and adding the rendered results to a custom field in the custom post endpoint: https://toolset.com/forums/topic/rest-api-v2-does-not-work-with-my-custom-post-type/
There is also an unofficial plugin available that claims to help expose Views and work with them in the REST API using a custom endpoint toolset-views: https://github.com/adrianosferreira/toolset-rest
You could use the plugin source as a reference for setting up your own custom solution, but as it is an unofficial plugin, we do not support it here in the forums.
We also have the Dynamic Sources API available for working with data in blocks, but I'm not sure if this is what you are interested in: https://toolset.com/documentation/programmer-reference/dynamic-sources-api/
If you have something specific you'd like to discuss, please provide more details and I can try to direct you to the correct documentation.
I'm trying to format in json a view ordered by distance and pagination.
Okay, since there is no JSON output formatting built-in to Views output, you would have to create the JSON structure manually in the View's loop editor and output editor using shortcodes.
- Do you have an example of the JSON format you would like to reproduce?
- What have you tried so far, can I see the results on the site somewhere? Is there a specific problem you are trying to fix in the output?