Newer Version Available
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).
Syntax
- URI
- /services/data/vXX.X/query?q=query
- Formats
- JSON, XML
- HTTP Method
- GET
- Authentication
- Authorization: Bearer token
- Parameters
Example
- Example Response Body
-
Resources for Running SOQL Queries
- 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 explain parameter, see Get Feedback on Query Performance.
-
For more information on SOQL in general, see the SOQL and SOSL Reference.