Disabling (or increasing size of) pagination

System Information
  • Strapi Version: 4.0.0
  • Operating System: Ubuntu 20.04
  • Database: Sqlite
  • Node Version: 14.18.2

Hello everyone.

A quick question: is there a straightforward way to disable pagination so that my query could return all results in one go? I have a collection of 300 items and I just need to return all of them in a single REST call. I have done a query with pagination[pageSize]=300, but it seems to be internally limited to 100.

I could just dig into the code, but maybe someone has a quick answer or point me to the bit of code that controls the max page size?

Kind regards, Strapi is amazing!

Hi @chrzan,

It is strongly suggested to keep the rate limit at 100, because it can cause performance and memory issues. However, you can modify these numbers in your API configuration.

// path: ./config/api.js

module.exports = ({ env }) => ({
  responses: {
    privateAttributes: ['_v', 'id', 'created_at'],
  },
  rest: {
    defaultLimit: 100,
    maxLimit: 250,
  },
});

I hope it helps!

Hi, how to really remove the limit. It seems that I can only change the limit number, not remove it entirely.

You can’t completely remove it. Just set the default and max to some huge number like 999999

I believe you should be able to set it as -1 and you can disable the limit. We obviously don’t recommend that.

where need to set -1 in maxLimit ? i set but it’s not working

Hello ,
i’d like to know if there is any way to do this on only certain api calls only instead of defining it globally to every api.

1 Like

What about Infinite?

Just out of sheer curiosity, what amount of items per page would be difficult? I’m building a small site rn with not that many visitors and I’m fetching some objects from the backend, the number of which will increase by 2 every year and right now I already have 50 Items or so. So over the estimated lifetime of the site I will have a maximum of 200 items which even the node-dev server can handle easily as of now. Say this were to increase to a thousand items, would this be problematic? Probably not in terms of client side waiting (which is negligible in this case) but more in terms of load on the server.

1 Like

The default and maximum values for pagination[limit] can be configured in the ./config/api.js file with the api.rest.defaultLimit and api.rest.maxLimit keys