Query Data using Query API
The Data 360 Query API provides a powerful way to execute SQL queries against your Data 360 data using Connect REST endpoints and Apex methods. This API supports Data 360 SQL syntax and is optimized for all Data 360 use cases, from simple data retrieval to complex analytics and integration scenarios.
The Query API enables you to:
- Execute SQL queries against data streams, profile, engagement, and unified data model objects
- Process large result sets with built-in pagination
- Access data through REST endpoints or Apex methods
- Integrate Data 360 data into external applications and workflows
Use the Connect REST API for most integration scenarios. It provides comprehensive features and integrates seamlessly with Salesforce Platform capabilities.
Base URL: https://{dne_cdpInstanceUrl}/services/data/v64.0/ssot/query-sql
-
- POST
https://{dne_cdpInstanceUrl}/services/data/v64.0/ssot/query-sql - Execute SQL queries asynchronously
- Returns query ID for tracking and result retrieval
- POST
-
- GET
https://{dne_cdpInstanceUrl}/services/data/v64.0/ssot/query-sql/{queryId} - Check query execution status and metadata
- Monitor progress for long-running queries
- GET
-
- GET
https://{dne_cdpInstanceUrl}/services/data/v64.0/ssot/query-sql/{queryId}/rows - Retrieve query results with pagination support
- Handle large datasets efficiently
- GET
-
- DELETE
https://{dne_cdpInstanceUrl}/services/data/v64.0/ssot/query-sql/{queryId} - Cancel running queries to free up resources
- Useful for query timeout management
- DELETE
For server-side integration within your Salesforce org, use the Apex ConnectAPI methods:
- Query SQL - Execute queries synchronously
- Query SQL Rows - Retrieve paginated results
- Cancel SQL Query - Cancel running queries
- Get SQL Query Status - Check query status
See OAuth 2.0 Client Credentials Flow for Server-to-Server Integration in the Salesforce Help Guide. All REST API calls require a valid OAuth 2.0 access token:
Apex methods use the current user's session context and permissions automatically. See Getting Started with Apex in the Apex Developer Guide.
- Filter early: Use WHERE clauses to reduce data scanned
- Select specific columns: Avoid
SELECT *statements - Limit results: Use
LIMITfor large datasets - Optimize joins: Include key qualifiers and proper indexing
- Consider your data’s indexed field: Use the DMOs primary index or consider using a secondary index
- Implement async handling: Data 360 queries use both asynchronous and synchronous responses to optimize performance. Setup your application to handle both sync and async responses.
- Paginate result sets: Use the Connect API
getSqlQueryRowsendpoint withoffsetandrowLimit. You can query yourcreateSqlQueryresults for 24 hours without incurring more consumption charges. Because Data 360 stores results,getSqlQueryRowsreturns data faster than calls tocreateSqlQuery.
Include key qualifier fields in table joins for optimal performance:
When key qualifiers aren't configured on data lake object fields, the value is null. Use IS NOT DISTINCT FROM for null-safe joins.
- Query Services Status Codes - Error handling reference
- Get Started With Data 360 SQL - SQL tutorial and examples
- Data 360 Metadata API - Explore available data objects
- API Limits and Guidelines - Usage limits and best practices
- Salesforce Developers Blog: Boost Data 360 Integrations with the New Query Connect API