Special parameters for API calls

Updated at:

The Data Resource Platform provides built-in request parameters. When you call an API, you can use these special parameters to add logic to the original query. This logic can include aggregation, sorting, and filtering returned fields. You can also include extra information in the results. This topic describes these special parameters.

Scenarios

A traffic management cloud control platform uses the Data Resource Platform to publish and manage data services. API developers for the transportation industry often write basic SQL queries that use only SELECT and WHERE clauses. After the API is published, callers can use special parameters to add sorting and aggregation logic to the basic query as needed. This allows a single service to adapt to different business scenarios. This reduces the developer workload and makes the API more flexible.

Usage

You can add the specified key and value to the query parameters during an API call. No prior declaration in the API is required.

Parameter list

Note

The keys for special parameters are system reserved words. Avoid using these names for your API parameters. Validation will be added in the future to prevent this issue.

Parameter

Description

Example value

return_fields

Specifies the fields to return. Use commas to separate multiple fields.

aa,bb,ccc

aggregation

Calculated field for aggregation (field to aggregate, operation, field name after aggregation).

Use semicolons to separate multiple aggregate functions.

salary,avg,avg_salary;birth_date,min,earliest_birth

group_by

Grouping field. Use commas to separate multiple fields.

xb,jj

order_by

Sorting field. The default is ascending order. Add 'desc' for descending order. Use commas to separate multiple fields.

aa desc,bb

page_size

Paging size.

10

page_token

Page number for paging. The next page number is also returned.

1

fetch_all

Specifies the total amount of query data to return.

true

return_lower_case

Converts the returned data to lowercase.

true

Usage examples

You can use a third-party tool to call the "Query Bank Customer Information" API. The returned raw data is as follows:

  • Suppose you want to retrieve data using paging and return 5 entries per page. Each entry must contain only the zzhm (certificate number), khmc (customer name), and yddh1 (phone) fields. The data must also be sorted in ascending order by nl (age). To do this, add the request parameters as shown in the following figure:

    image

    Click Send to make the call. The result is as follows:

    image

    total is the total number of data entries from the query, timeCost is the time taken for this request, and next_page_token is the token for retrieving the next page.

  • To calculate the average salary (gz) for each education level (jysp) and then sort the results in ascending order, add the parameters as shown in the figure:

    image

    Click Send to make the call. The result is as follows:

    image