How we can limit the number of rows in api call



I am trying to access data of dataset using api and fetched the data using below api.{DATASET_ID}/data


But it provide all the data, How we can limit the number of rows in api call?
Please provide us the link if have any.



  • dthierjung

    You can potentially leverage the column filter options as listed at the top of this page, but it doesn't explicitly state the number of rows that you can retrieve: 



    I don't think they offer the capability to limit the row return count just yet though for the Dataset API.

  • WHM
    WHM Contributor

    You can user the "query a dataset" version of the dataset API. It works great for aggregating data, even from large datasets. here is a powershell example of the query:


    $query = '{"sql": "select sum(gross_sales_less_returns) from table where fiscal_date = '+"'" +$Yesterday +"'::DATE group by fiscal_date"+'"}'


    The call then looks like this:


    $data = Invoke-RestMethod -Method POST -Uri "$datasetId" -body $query -Headers $headers -ContentType 'application/json;charset=UTF-8'

    I check the amount of yesterday's sales in case something broke upstream and my dataset updated with nothing from yesterday before sending out reports. 


    Hope that helps. 



This discussion has been closed.