API configuration
The content of this page might not be fully up-to-date with Strapi 5 yet.
General settings for API calls can be set in the ./config/api.js
file:
Property | Description | Type | Default |
---|---|---|---|
responses | Global API response configuration | Object | - |
responses.privateAttributes | Set of globally defined attributes to be treated as private. | String array | [] |
rest | REST API configuration | Object | - |
rest.prefix | The API prefix | String | /api |
rest.defaultLimit | Default limit parameter used in API calls (see REST API documentation) | Integer | 25 |
rest.maxLimit | Maximum allowed number that can be requested as limit (see REST API documentation). | Integer | 100 |
Note
If the rest.maxLimit
value is less than the rest.defaultLimit
value, maxLimit
will be the limit used.
Example:
- JavaScript
- TypeScript
./config/api.js
module.exports = ({ env }) => ({
responses: {
privateAttributes: ['_v', 'id', 'created_at'],
},
rest: {
prefix: '/v1',
defaultLimit: 100,
maxLimit: 250,
},
});
./config/api.ts
export default ({ env }) => ({
responses: {
privateAttributes: ['_v', 'id', 'created_at'],
},
rest: {
prefix: '/v1',
defaultLimit: 100,
maxLimit: 250,
},
});