Enable the Data API
SingleStore’s Data API is accessible via a built-in HTTP server. The Data API is enabled by default. When the Data API is enabled, it will be hosted on a port that is different from the SingleStore port.
Test the Data API
Call the GET /ping
API request to verify that the HTTP service is running and connectable. To perform this action using cURL, invoke a GET request to the /ping
endpoint with no parameters, as shown below.
curl https://svc-10444e3f-afeb-46be-b186-a8c64b99f726-dml.aws-ireland-1.svc.singlestore.com/ping
If the Data API service is available and is able to respond to requests, you will receive the following response along with a 200 OK status code, indicating a successful HTTP response.
pong
If an error occurs, you will receive one of the HTTP response status codes listed here along with the error description in the response body. For more information, refer to the Data API Endpoint Reference.
The GET /ping
request can only verify whether the HTTP service is running and connectable. To verify that the database can receive queries, use the /exec
and /query
endpoints as shown below.
The following cURL command invokes a POST API request to the /query/rows
endpoint. (Note that you need to replace root:password
in the HTTP request with your SingleStore username:password
string.)
curl -H "Content-Type: application/json" --data '{"sql": "select 1+1"}' --user 'root:password' https://svc-10444e3f-afeb-46be-b186-a8c64b99f726-dml.aws-ireland-1.svc.singlestore.com/api/v2/query/rows
If the API call is successful, you should see the following results along with a 200 OK status line.
{"results":[{"rows":[{"1+1":2 }]}]}
If an error occurs, you will receive one of the HTTP response status codes listed here along with the error description in the response body. For more information, refer to the Data API Endpoint Reference.
If you format the JSON output with a formatting tool, the results would appear as follows. (Recommended JSON formatting tools: jq, JSONLint)
{ "results": [ { "rows": [ { "1+1": 2 } ] } ] }
Note: The GET /ping
request should be used in automated health checks. To verify specific health metrics, use the /exec
and /query
endpoints.