A complexity score is calculated for each request that is made to the JSON:API content delivery API. This score is calculated based on the number of resources that could potentially be returned and the types of those resources.
There are two types of resources which can be returned, with each one contributing a different amount to the overall complexity score:
You can use the x-lexascms-query-complexity
response header to determine the complexity score that was calculated for any given request.
The maximum complexity score that is allowed for a single request is 5000
. In the event that this is exceeded, an error will be returned.
For the below example, imagine we have a book
content type which along with some basic scalar fields has an author
relationship field and a reviews
relationship field.
The below example would carry a complexity score of 290
GET /book/1234?include=author,reviews
# Calculation Breakdown:
#
# 50 (Root Resource)
# 10 (Book Item)
# 10 (Author Relationship)
# 10 (Author Item)
# 10 (Reviews Relationship)
# 200 (20 x Review Items)
# ===
# 290
You can reduce the complexity store of your requests by using pagination to limit the number of resources that could be returned.
The complexity score of the previous example could be reduced to 140
by using pagination to limit the number of reviews that can be returned:
GET /book/1234?include=author,reviews&page[reviews][limit]=5
# Calculation Breakdown:
#
# 50 (Root Resource)
# 10 (Book Item)
# 10 (Author Relationship)
# 10 (Author Item)
# 10 (Reviews Relationship)
# 50 (5 x Review Items)
# ===
# 140
© 2022 Status200 Ltd.