Special parameters for API calls

Updated at:

A set of built-in request parameters is provided for API calls. You can use these special parameters to add extra logic to the original query, such as aggregation, sorting, and filtering the returned fields. You can also use these parameters to include additional information in the results.

Scenarios

A common scenario is the Traffic Management Cloud Control Platform. It uses Data Resource Platform to publish and manage data services. API developers for the transportation industry often write basic SQL queries for these services. For example, a query might only use `SELECT` and `WHERE` clauses. After the API is published, callers can use special parameters to add more complex logic, such as sorting and aggregation. This allows a single service to adapt to different business needs. It also reduces 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.

Parameters

Parameter Name

Description

Example value

return_fields

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

​aa,bb,ccc

aggregation

The calculated field for aggregation. The format is: "field_to_aggregate,operation,aggregated_field_name". Use semicolons to separate multiple aggregate functions.

salary,avg,average_salary;dob,min,earliest_birthdate

group_by

The grouping field. Use commas to separate multiple fields.

gender,level

order_by

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

aa desc,bb

page_size

The page size for paging.

10

page_token

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

1

fetch_all

The total number of entries returned by the query.

true

return_lower_case

Converts the returned data to lowercase.

true

Note
  • The final paging result is based on `page_size` and `page_token`.

  • If the current API already implements paging (such as by adding `limit` or `offset` in the SQL), including these paging parameters in the request performs secondary paging on the original paged results.

  • To view the data volume returned by the query without performing secondary paging, you can use the `fetch_all` parameter.

Examples

Original response from the "Query Bank Customer Information List" API:

1. This example retrieves data by page. It returns 5 records per page. Each record includes only the `zzhm` (certificate number), `khmc` (customer name), and `yddh1` (phone number) fields. The results are sorted in ascending order by `nl` (age). To do this, you can add the request parameters as shown in the figure:

The response is:

image.png

`total` is the total data volume from the query, `timeCost` is the time taken for this request, and `next_page_token` is the token for the next page.

​

2. This example calculates the average salary (`gz`) grouped by education level (`jysp`). The results are then sorted in ascending order. To do this, you can add the parameters as shown in the figure:

The response is:

image.png​

Note

The keys for these special parameters are system reserved words. Avoid using these names for your own API parameters. A validation check will be added in the future to prevent naming conflicts.