Score:1

How to retrieve all taxonomy term using json api

th flag

I want to retrieve all taxonomy term name using json api.

I have tried:

http://local-tes/jsonapi/taxonomy_term/specialties

but its only return 50 values, I want to fetch all taxonomy terms values.

Kevin avatar
in flag
I believe this is capped so the application doesn't crash from loading hundreds+ of potential entities. You'll need to loop and paginate over it or use a contrib module that increases the number returned.
Score:1
cn flag

See https://www.drupal.org/docs/core-modules-and-themes/core-modules/jsonapi-module/pagination#s--cant-i-set-a-page-limit-higher-than-50:

Why can't I set a page limit higher than 50?

First, read the example given above. Understand that JSON:API must run individual access checks for every entity in a response. Second, understand that the JSON:API module aims to be "zero configuration." You shouldn't have to install, alter or configure anything to use the module.

The reason for this is to protect your application from a DDoS attack. If a malicious API client set a page limit of 200,000 resources, the JSON:API module would need to run entity access checks for every one of those entities. This would quickly lead to out-of-memory errors and slow responses. The server needs to set a maximum. The limit of 50 was somewhat arbitrarily chosen as a nice round number.

Please understand that there have been many long conversations around this decision and a compromise had to be made between support burden, sane defaults, and frontend performance. While the JSON:API module maintainers do understand that this may not be ideal for every use case, they're confident that if your client follows the recommendations in these docs, it should have little to no impact on you :)

There is the JSON:API Page Limit module and also JSON API Defaults (part of the popular JSON:API Extras module) to change the limit.

After you have installed the JSON API Defaults module go to

http://example.com/admin/config/services/jsonapi/add/resource_types/taxonomy_term/[vocabulary]

and change the page limit at the bottom of the config form.

Then you can request a higher number of items with the query parameter page[limit]:

http://example.com/jsonapi/taxonomy_term/[vocabulary]?page[limit]=1000

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.