Using the Turbot Pipes Query API
Authentication
To use the Turbot Pipes API, you must connect with an
API token. The examples in this section assume
that you have set the
PIPES_TOKEN to a valid
API token:
export PIPES_TOKEN=tpt_c6rnjt8afakemj4gha10_svpnmxqfaketokenad431kQuery Your Data
The Turbot Pipes API makes it easy to query your data and integrate it into your scripts and applications!
You can issue a simple query with a GET request:
curl -H "Authorization: Bearer ${PIPES_TOKEN}" \ https://pipes.turbot.com/api/latest/user/foo/workspace/bar/query?sql=select+*+from+aws_s3_bucketIf you POST, you can avoid encoding the SQL:
curl -H "Authorization: Bearer ${PIPES_TOKEN}" \ -d 'sql=select name,arn from aws_s3_bucket' \ https://pipes.turbot.com/api/latest/user/foo/workspace/bar/queryBy default, the results are in JSON. You can get the results in other formats by adding a file name with the appropriate extension to the path. You can get your results in CSV:
curl -H "Authorization: Bearer ${PIPES_TOKEN}" \ -d sql'=select name,arn from aws_s3_bucket' \ https://pipes.turbot.com/api/latest/user/foo/workspace/bar/query/my-file.csvOr markdown:
curl -H "Authorization: Bearer ${PIPES_TOKEN}" \ -d sql'=select name,arn from aws_s3_bucket' \ https://pipes.turbot.com/api/latest/user/foo/workspace/bar/query/my-file.mdAlternatively, you can set the content type in the content_type query
parameter:
curl -H "Authorization: Bearer ${PIPES_TOKEN}" \ -d sql'=select name,arn from aws_s3_bucket' \ https://pipes.turbot.com/api/latest/user/foo/workspace/bar/query?content_type=csvOr via HTTP headers:
curl -H "Authorization: Bearer ${PIPES_TOKEN}" \ -H "Accept: text/csv" \ -X POST -d sql='select name,arn from aws_s3_bucket' \ https://pipes.turbot.com/api/latest/user/foo/workspace/bar/query