How do i set limit query into url from views output In drupal i need to output json fields. So i used views_datasource. In my situation, i need to call same api source to multiple section, but i don't want to create multiple view only for 5 items or 10 items or all items for same content types data. So in views_datasource i need to use limit filter from all of views results like "http://example.com/serve/all-articles?limit=10". 

Can anybody help me to do it?
Ccreate a custom module and implement hook_views_pre_build. 

To create the module follow these steps:

In sites/all/modules create a new folder with the name of your module. As you are not contributing this module back to Drupal and it is specific to your project just give it the name of your project and other code tweaks can also live in there.

Let's assume you called your project custom_project and it is at sites/all/modules/custom_project. 

Add a file called custom_project.info to it with this content:

name = Custom Project Module     
description = This module is for project related tweaks     
core = 7.x


Add a file called custom_project.module with this content:

&lt;?php
function custom_project_views_pre_build(&amp;$view){
  if ($view-&gt;name == "NAMEOFVIEW") {
    if (isset($view-&gt;args[0]) &amp;&amp; is_numeric($view-&gt;args[0])) {
      $view-&gt;set_items_per_page($view-&gt;args[0]);
    }
  }
}


Now install this module (and in future if you add any hooks then clear the cache)

You call this on a friendly url ("http://example.com/serve/all-articles/10"). 

If you wish to add a query parameter to the url as in "http://example.com/serve/all-articles?limit=10" then your function will need to inspect drupal_get_query_parameters for that parameter instead of pulling it out of $view-&gt;args[0].

ie.:

&lt;?php
function custom_project_views_pre_build(&amp;$view){    
  if ($view-&gt;name == "NAMEOFVIEW") {    
    $query_params = drupal_get_query_parameters();    
    if (isset($query_params['limit']) &amp;&amp; is_numeric($query_params['limit'])) {    
      $view-&gt;set_items_per_page($query_params['limit']);    
    }    
  }    
}


You need to replace NAMEOFVIEW with your views name. You get it like this:



Note that a view has a name, but also a display id. The display id in this case is page. If you add a block it will get a block display id. So the above code will work for all displays that you add to this view, even for blocks etc. To limit it to just the page you will change the one line to this:

if ($view-&gt;name == "all_content_of_article" &amp;&amp; $view-&gt;current_display == "page") {