Query
Runs the specified SOQL query.
When a SOQL query is executed, up to 2,000 records can be returned at a time in a synchronous request. However, to optimize performance, the returned batch can include fewer records than the limit or what’s set in the request, based on the size and complexity of records queried. If the total number of results exceeds the limit or the requested number of results, the response contains the first batch of records, a false value for done, and a query locator. You can use the query locator with the Query More Results resource to retrieve the next batch of records.
The response contains the total number of records returned by the Query request (totalSize), a boolean indicating whether there are no more results (done), the URI of the next set of records (nextRecordsUrl), and an array of query result records (records).
URI: /services/data/vXX.X/query?q=query
Formats: JSON, XML
HTTP Method: GET
Authentication: Authorization: Bearer token
Parameters
| Parameter | Description |
|---|---|
q | A SOQL query. To create a valid URI, replace spaces in the query string with a plus sign + or with %20. For example: SELECT+Name+FROM+MyObject. If the SOQL query string is invalid, a MALFORMED_QUERY response is returned. |
Example Response Body
- For an example, see Execute a SOQL Query.
- To change the batch size, see Query Options Header.
- To get feedback on a query and a report by using the
explainparameter, see Get Feedback on Query Performance. - For more information on SOQL in general, see the SOQL and SOSL Reference.