Export a query on the public data model

Content

Resource URL

https://apps.ticketmatic.com/api/1/{accountname}/tools/queries/export

Description

Executes a query against the public data model and exports the results as a stream of JSON lines: each line contains a JSON object which holds one row of the query result.

Example

Request

1use Ticketmatic\Endpoints\Tools;
2
3$result = Tools::export($client, array(
4    "limit" => 250,
5    "offset" => 500,
6    "query" => "SELECT * FROM tm.paymentscenario",
7));

Request

 1import (
 2    "github.com/ticketmatic/tm-go/ticketmatic"
 3    "github.com/ticketmatic/tm-go/ticketmatic/tools"
 4)
 5
 6result, err := tools.Export(client, &ticketmatic.QueryRequest{
 7    Limit: 250,
 8    Offset: 500,
 9    Query: "SELECT * FROM tm.paymentscenario",
10})

Request

1POST /api/1/{accountname}/tools/queries/export HTTP/1.1
2Content-Type: application/json
3
4{
5    "limit": 250,
6    "offset": 500,
7    "query": "SELECT * FROM tm.paymentscenario"
8}

Request body fields

FieldDescription
limit
int 
(required)

Optional limit for the result. Default 100

Example value:250
offset
int 
(required)

Optional offset for the result. Default 0

Example value:500
query
string 
(required)

Actual query to execute

Example value:"SELECT * FROM tm.paymentscenario"

Type reference: QueryRequest

Result stream

This call returns a stream of objects.

Usage example

You can iterate over each result by repeatedly calling the next() method on the returned object.

1while ($item = $result->next()) {
2    // Do something with $item
3}

Usage example

You can iterate over each result by repeatedly calling the Next() method on the returned object. You must call Close() when done.

 1defer result.Close()
 2for {
 3    item, err := result.Next()
 4    if err != nil {
 5        return err
 6    }
 7    if item == nil {
 8        break
 9    }
10
11    // Do something with item
12}

Usage example

Each line of the response contains a JSON object. Lines are delimited by newlines (\n).