Skip to content

SolarQuery API global objects

Matt Magoffin edited this page Dec 4, 2013 · 13 revisions

This page lists objects used throughout the SolarQuery API.

Paged results object

Many API methods can return large sets of data, but SolarQuery will break up the results into smaller paged response objects that contain just a subset of the overall data. The response object contains details on the total number of available results along with the starting offset of the returned results:

{
  "success": true,
  "data": {
    "results": [...],
    "totalResults": 2384790,
    "startingOffset": 0,
    "returnedResultCount": 250
  }
}

In the preceding example, 2384790 results are available, but only the first 250 results have been returned in the data array. To get the next set, or page, of results you'd call the same method again but provide a 0-based starting offset for the desired first result. In this case, an offset of 250 would return the next page, which would result in a response like:

{
  "success": true,
  "data": {
    "results": [...],
    "totalResults": 2384790,
    "startingOffset": 250,
    "returnedResultCount": 250
  }
}

Paged query parameters

For API methods that return paged results objects, the following query parameters are used to specify the page attributes:

max A positive integer for the maximum number of results to return in the response. SolarQuery might limit the number of returned results and ignore this value if it is too large.
offset A non-negative integer for the starting offset of the results to return in the response. When combined with the max parameter you can get individual _pages_ of results from the overall result set.

Example

An example URL query string to return page 2 of a result set using 100 results per page:

?max=100&offset=100

Sort query parameters

For API methods that support sorting the result, an array of sort descriptors can be provided on the sorts query parameter. Array parameters must be specified as sort[x].y where x is a 0-based index that specifies the order of the sort descriptor and y is the sort descriptor property as detailed here:

sortKey The name of the property to sort the results by. Typically this will correspond to the name of an attribute in the returned result objects. For example to sort a location search by name, a query parameter like sorts[0].sortKey=locationName might be appropriate. Consult the documentation for individual API methods for details on the supported sortKey values.
descending A boolean indicating the sort should be in descending (true) or ascending (false) order. By default this value is false so sorts will be applied in ascending order if this is not specified.

Example

An example URL query string to sort by creation in descending order:

?sorts%5B0%5D.sortKey=created&sorts%5B0%5D.descending=true
Clone this wiki locally