Execute a query on the public data model

Content

Resource URL

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

Description

Use this method to execute random (read-only) queries on the public data model. Note that this is not meant for long-running queries or for returning large resultsets. If the query executes too long or uses too much memory, an exception will be returned.

Example

Request

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

Response

 1object(\Ticketmatic\Model\QueryResult) (2) {
 2  ["nbrofresults"]=>
 3  int(0)
 4  ["results"]=>
 5  array(2) {
 6    [0]=>
 7    array(2) {
 8      ["id"]=>
 9      float(123.000000)
10      ["name"]=>
11      string(4) "Cash"
12    }
13    [1]=>
14    array(2) {
15      ["id"]=>
16      float(124.000000)
17      ["name"]=>
18      string(11) "Credit Card"
19    }
20  }
21}

Request

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

Response

 1result := &ticketmatic.QueryResult{
 2    Nbrofresults: 723,
 3    Results: []map[string]interface{}{
 4        map[string]interface{}{
 5            "id": 123,
 6            "name": "Cash",
 7        },
 8        map[string]interface{}{
 9            "id": 124,
10            "name": "Credit Card",
11        },
12    },
13}

Request

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

Response

 1HTTP/1.1 200 OK
 2Content-Type: application/json
 3
 4{
 5    "nbrofresults": 723,
 6    "results": [
 7        {
 8            "id": 123.000000,
 9            "name": "Cash"
10        },
11        {
12            "id": 124.000000,
13            "name": "Credit Card"
14        }
15    ]
16}

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 fields

FieldDescription
nbrofresults
int

The number of rows in the result

Example value:723
results
map<string, mixed>[]

The actual resulting rows

Example value:[ { "id": 123.000000, "name": "Cash" }, { "id": 124.000000, "name": "Credit Card" } ]

Type reference: QueryResult