Patch #16069

Allow configuration of API limit instead of hardcoding at 100

Added by Domingo Galdos over 5 years ago. Updated 5 months ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:


Category:REST API
Target version:Candidate for next major release


The below tested patch makes the previously harcoded limit of 100 items in a RESTful API response configurable in the Administration GUI. The default value is still 100. This is based on 2.4.1.stable.

This is quite useful since it is nice and simple to just get the full response in a single page rather than having to traverse pagination, and a limit of a bit more than 100 is still very performant for many sites -- the limit beyond which performance starts to degrade really depends on the particular site's usage, so should be controllable by the local administrator.

Index: app/controllers/application_controller.rb
--- app/controllers/application_controller.rb       (.../trunk/app) (revision 13385)
+++ app/controllers/application_controller.rb       (.../branches/code-8112/app)    (revision 13389)
@@ -519,8 +519,8 @@
     limit = options[:limit].to_i
     if limit < 1
       limit = 25
-    elsif limit > 100
-      limit = 100
+    elsif limit > Setting.api_limit.to_i
+      limit = Setting.api_limit.to_i
     if offset.nil? && options[:page].present?
       offset = (options[:page].to_i - 1) * limit
Index: app/views/settings/_general.html.erb
--- app/views/settings/_general.html.erb    (.../trunk/app) (revision 13385)
+++ app/views/settings/_general.html.erb    (.../branches/code-8112/app)    (revision 13389)
@@ -24,6 +24,8 @@

 <p><%= setting_select :wiki_compression, [['Gzip', 'gzip']], :blank => :label_none %></p>

+<p><%= setting_text_field :api_limit, :size => 6 %></p>
 <p><%= setting_text_field :feeds_limit, :size => 6 %></p>

 <p><%= setting_text_field :file_max_size_displayed, :size => 6 %> <%= l(:"number.human.storage_units.units.kb") %></p>
Index: config/settings.yml
--- config/settings.yml        (revision 13387)
+++ config/settings.yml        (revision 13389)
@@ -73,6 +73,9 @@
   default: localhost:3000
   default: http
+  format: int
+  default: 100
   format: int
   default: 15
Index: config/locales/en.yml
--- config/locales/en.yml      (revision 13387)
+++ config/locales/en.yml      (revision 13389)
@@ -352,6 +352,7 @@
   setting_host_name: Host name and path
   setting_text_formatting: Text formatting
   setting_wiki_compression: Wiki history compression
+  setting_api_limit: Maximum number of items returned in a JSON/XML API response
   setting_feeds_limit: Maximum number of items in Atom feeds
   setting_default_projects_public: New projects are public by default
   setting_autofetch_changesets: Fetch commits automatically

Related issues

Duplicated by Redmine - Feature #7539: Rest-API limit of items not 100, but changeable by the ad... Closed 2011-02-04
Duplicated by Redmine - Defect #25555: Make api paging limit configurable Closed
Duplicated by Redmine - Feature #26553: Overly restricted number of ReST results Closed


#1 Updated by Domingo Galdos about 5 years ago

Is there anything I can do to help move this patch forward?

#2 Updated by Anton Statutov about 4 years ago


#3 Updated by V Lindell about 4 years ago


#4 Updated by Toshi MARUYAMA about 4 years ago

  • Target version set to 3.2.0

#5 Updated by Go MAEDA about 4 years ago

The user should not be able to set the value of API limit smaller than 100.
Probably some clients suppose that the value is always 100, smaller limit may affect compatibility with such clients.

#6 Updated by Jens Peter Kempkes almost 4 years ago

We would also appreciate higher values than 100. Some of our tools need to load all items visible to a user and therefore need to split the requests.

#7 Updated by Sebastian Paluch over 3 years ago


#8 Updated by Jean-Philippe Lang over 3 years ago

  • Target version changed from 3.2.0 to Candidate for next major release

#9 Updated by Jens Peter Kempkes over 3 years ago

Too sad, this patch was shifted.
What is the reason?

We're really waiting for this patch and all seems to be done. Am I wrong?

#10 Updated by Niklaus Jordi over 3 years ago


#11 Updated by Go MAEDA over 3 years ago

  • Duplicated by Feature #7539: Rest-API limit of items not 100, but changeable by the administrator added

#12 Updated by Dam Dam about 3 years ago


This request was posted 2 years ago, so what's up?

#13 Updated by Stephane Evr almost 3 years ago


#14 Updated by Go MAEDA over 2 years ago

  • Duplicated by Defect #25555: Make api paging limit configurable added

#15 Updated by George Brooke over 2 years ago

Is there anything wrong/non-ideal with this patch which means that it has not been integrated?

#16 Updated by Bohdan Artemchuk about 2 years ago


#17 Updated by Toshi MARUYAMA about 2 years ago

  • Description updated (diff)

#18 Updated by Toshi MARUYAMA about 2 years ago

  • Duplicated by Feature #26553: Overly restricted number of ReST results added

#19 Updated by Michael Gerz over 1 year ago

What happened to this patch? Nothing?

#20 Updated by Jose Luis Parrilla over 1 year ago


#21 Updated by Гордеев Алексей 12 months ago

Silence... :(

#22 Updated by Yuuki NARA 6 months ago


I think that it should be changeable by the responsibility of the system administrator.

There are many configuration items in the world system that may cause troubles due to setting change contents.
Since there are cases where it is necessary to change these items, it is made public after clearly stating that there is a risk when changing.

It is enough to specify the following points.

If you change the default value, there is a possibility of trouble in the operation of REST using application.
The operation verification responsibility is on Redmine system administrator who changed.

#23 Updated by C F 6 months ago


#24 Updated by Gianni Cavallotto 5 months ago


Also available in: Atom PDF