The tag history system.tag.* calls are the "premade" query.
Fundamentally, you will be search for the set of tag ids that correspond to your tag path, and the set of partitions that correspond to your time range. Then you will construct a query that unions those partitions together after filtering each for the desired tag and time.
There isn't a single generic query that can do this.
It's working if to set the "start time, end time and interval time", but I couldn't figure out how to return only a fixed amount of data points.
For example I want to return only 200 data point, doesn't matter whether it's duration of 1 day or 1 month, for the 200 data point, I can either choose average or last value.
I found the following statement in the doc, but I don't know whether it's the same meaning of "fixed size" as I want.