Orders provides a list of all orders which can filtered based on provided parameters.

🚧

Make sure to replace [TT LAN IP]!

[TT LAN IP] in the example code provided is what should be replaced by what the local area network (LAN) assigned address of the Table Tracker gateway. (e.g. 192.168.1.232, 10.0.1.13, 192.168.0.324)

Please note that the code examples provided are only meant to provide an idea of what making a HTTP request to the API looks like.

GET /api/v1/orders?{&offset,limit,created_after,created_before,order_type,location_name}

Retrieve a list of orders in the system, starting at offset and returning a maximum limit of orders.

Parameters

NameDescriptionDetails
offsetThe starting point of the list.positive number, optional
default: 0
limitThe max number of orders to retrieve.positive number, optional
default: 25
max: 100
created_afterA query parameter to limit search to orders created after a specific datetime.datetime, optional
Date should be in format:
YYYY-MM-DD HH:MM:SS
created_beforeA query parameter to limit search to orders created before a specific datetime.datetime, optional
Date should be in format:
YYYY-MM-DD HH:MM:SS
order_typeA query parameter to limit search to orders of a particular type.string, optional
Valid values:
TO_GO
ON_PREMISE
location_nameA query parameter to limit search to orders at a particular location.positive number, optional

Request

// Order Query Example 1 (GET http://[TT LAN IP]:8000/api/v1/orders)

$.ajax({
    url: "http://[TT LAN IP]:8000/api/v1/orders",
    type: "GET",
    data:{
        "created_after":"2014-09-23T15:56:08+00:00",
    },
    headers:{
        "Authorization":"Basic MGE5YWViNDQtNjU0Yy00NGRjLWFhMjYtNjA5YWQzMTg2NTRkOg==",
        "Content-Type":"application/json",
    },
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});
import java.io.IOException;
import org.apache.http.client.fluent.*;

public class SendRequest
{
  public static void main(String[] args) {
    sendRequest();
  }
  
  private static void sendRequest() {
    
    // Order Query Example 1 (GET )
    
    try {
      
      // Create request
      Content content = Request.Get("http://[TT LAN IP]:8000/api/v1/orders?created_after=2014-09-23T15%3A56%3A08%2B00%3A00")
      
      // Add headers
      .addHeader("Authorization", "Basic MGE5YWViNDQtNjU0Yy00NGRjLWFhMjYtNjA5YWQzMTg2NTRkOg==")
      .addHeader("Content-Type", "application/json")
      
      // Fetch request and return content
      .execute().returnContent();
      
      // Print content
      System.out.println(content);
    }
    catch (IOException e) { System.out.println(e); }
  }
}
// Order Query Example 1 (GET http://[TT LAN IP]:8000/api/v1/orders)

NSURL* URL = [NSURL URLWithString:@"http://[TT LAN IP]:8000/api/v1/orders"];
NSDictionary* URLParams = @{
    @"created_after": @"2014-09-23T15:56:08+00:00",
};
URL = NSURLByAppendingQueryParameters(URL, URLParams);
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:URL];
request.HTTPMethod = @"GET";

// Headers

[request addValue:@"Basic MGE5YWViNDQtNjU0Yy00NGRjLWFhMjYtNjA5YWQzMTg2NTRkOg==" forHTTPHeaderField:@"Authorization"];
[request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];

// Connection

NSURLConnection* connection = [NSURLConnection connectionWithRequest:request delegate:nil];
[connection start];

/*
 * Utils: Add this section before your class implementation
 */

/**
 This creates a new query parameters string from the given NSDictionary. For
 example, if the input is @{@"day":@"Tuesday", @"month":@"January"}, the output
 string will be @"day=Tuesday&month=January".
 @param queryParameters The input dictionary.
 @return The created parameters string.
*/
static NSString* NSStringFromQueryParameters(NSDictionary* queryParameters)
{
    NSMutableArray* parts = [NSMutableArray array];
    [queryParameters enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
        NSString *part = [NSString stringWithFormat: @"%@=%@",
            [key stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding],
            [value stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]
        ];
        [parts addObject:part];
    }];
    return [parts componentsJoinedByString: @"&"];
}

/**
 Creates a new URL by adding the given query parameters.
 @param URL The input URL.
 @param queryParameters The query parameter dictionary to add.
 @return A new NSURL.
*/
static NSURL* NSURLByAppendingQueryParameters(NSURL* URL, NSDictionary* queryParameters)
{
    NSString* URLString = [NSString stringWithFormat:@"%@?%@",
        [URL absoluteString],
        NSStringFromQueryParameters(queryParameters),
    ];
    return [NSURL URLWithString:URLString];
}
curl -X "GET" "http://[TT LAN IP]:8000/api/v1/orders?created_after=2014-09-23T15%3A56%3A08%2B00%3A00" \
	-H "Authorization: Basic MGE5YWViNDQtNjU0Yy00NGRjLWFhMjYtNjA5YWQzMTg2NTRkOg==" \
	-H "Content-Type: application/json"
# Install the Python Requests library:
# `pip install requests`

import requests

def send_request():
    # Order Query Example 1 (GET http://[TT LAN IP]:8000/api/v1/orders)

    try:
        r = requests.get(
            url="http://[TT LAN IP]:8000/api/v1/orders",
            params = {
                "created_after":"2014-09-23T15:56:08+00:00",
            },
            headers = {
                "Authorization":"Basic MGE5YWViNDQtNjU0Yy00NGRjLWFhMjYtNjA5YWQzMTg2NTRkOg==",
                "Content-Type":"application/json",
            },
        )
        print('Response HTTP Status Code : {status_code}'.format(status_code=r.status_code))
        print('Response HTTP Response Body : {content}'.format(content=r.content))
    except requests.exceptions.RequestException as e:
        print('HTTP Request failed')

Response 200 (application/json)

{
          "status": 200,
          "count": "7",
          "items": [
            {
              "locationName": null,
              "orderLocated": null,
              "uuid": "9e1da5eb-59ea-4003-9c1c-15160879c88d",
              "orderCleared": "2014-08-21T10:00:41+00:00",
              "orderType": "ON_PREMISE",
              "orderStarted": "2014-08-21T10:00:36+00:00",
              "type": "ORDER_SUMMARY",
              "name": "66"
            },
            {
              "locationName": null,
              "orderLocated": null,
              "uuid": "5d968a9c-77ec-41fd-aae8-54ef025b0f0d",
              "orderCleared": "2014-08-21T10:00:47+00:00",
              "orderType": "ON_PREMISE",
              "orderStarted": "2014-08-21T10:00:43+00:00",
              "type": "ORDER_SUMMARY",
              "name": "87"
            },
            {
              "locationName": "10",
              "orderLocated": "2014-08-21T10:05:55+00:00",
              "uuid": "85717acb-a36c-4cd1-847c-f3675f70f2e1",
              "orderCleared": "2014-08-21T10:06:04+00:00",
              "orderType": "ON_PREMISE",
              "orderStarted": "2014-08-21T10:05:27+00:00",
              "type": "ORDER_SUMMARY",
              "name": "66"
            },
            {
              "locationName": null,
              "orderLocated": null,
              "uuid": "57d5ad34-9977-44dc-8406-c1ece92ff85c",
              "orderCleared": "2014-08-21T13:13:57+00:00",
              "orderType": "ON_PREMISE",
              "orderStarted": "2014-08-21T13:13:35+00:00",
              "type": "ORDER_SUMMARY",
              "name": "87"
            },
            {
              "locationName": null,
              "orderLocated": null,
              "uuid": "27db2828-aa6d-44ab-8015-ac5b142be4e7",
              "orderCleared": "2014-08-21T13:13:46+00:00",
              "orderType": "ON_PREMISE",
              "orderStarted": "2014-08-21T13:13:33+00:00",
              "type": "ORDER_SUMMARY",
              "name": "66"
            },
            {
              "locationName": null,
              "orderLocated": null,
              "uuid": "f73e89fe-c32c-4595-9b8a-ad8dcf9791c6",
              "orderCleared": "2014-08-25T07:57:56+00:00",
              "orderType": "ON_PREMISE",
              "orderStarted": "2014-08-25T06:57:45+00:00",
              "type": "ORDER_SUMMARY",
              "name": "66"
            },
            {
              "locationName": "10",
              "orderLocated": "2014-08-21T10:05:59+00:00",
              "uuid": "a677aae2-d064-47d8-9ee3-8232da559b38",
              "orderCleared": "2014-08-21T10:06:01+00:00",
              "orderType": "ON_PREMISE",
              "orderStarted": "2014-08-21T10:05:19+00:00",
              "type": "ORDER_SUMMARY",
              "name": "87"
            }
          ]
        }

Response 400 (application/json)

Returns if limit is not a valid positive number.

{
  "status": 400,
  "message": "Invalid value for limit. Must be a positive integer."
}

Response 400 (application/json)

Returns if offset is not a valid positive number.

{
  "status": 400,
  "message": "Invalid value for offset. Must be a positive integer."
}

Response 412 (application/json)

Returns if limit is greater than the maximum limit: 100

{
  "status":412,
  "message":"Precondition failed limit should not be greater than 100"
}

Response 400 (application/json)

Returns if created_before or created_after is not in the correct format: YYYY-MM-DD HH:MM:SS

{
  "status": 400,
  "message": "created_after parameter does not match format YYYY-MM-DD HH:MM:SS."
}
{
  "status": 400,
  "message": "created_before parameter does not match format YYYY-MM-DD HH:MM:SS."
}

Response 400 (application/json)

Returns if locationName provided is not a valid positive number.

{
  "status": 400,
  "message": "Location name must be a positive integer."
}

GET /api/v1/orders/{uuid}

Retrieve a single order by its uuid.

Parameters

uuidThe UUID of the order to retrieve.string, required

Request

// Get Order by UUID (GET http://10.0.1.2:8000/api/v1/orders/4d033706-a736-459e-9db0-3727b89c198b)

$.ajax({
    url: "http://[TT LAN IP]:8000/api/v1/orders/4d033706-a736-459e-9db0-3727b89c198b",
    type: "GET",
    headers:{
        "Authorization":"Basic MGE5YWViNDQtNjU0Yy00NGRjLWFhMjYtNjA5YWQzMTg2NTRkOg==",
        "Content-Type":"application/json",
    },
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});
import java.io.IOException;
import org.apache.http.client.fluent.*;

public class SendRequest
{
  public static void main(String[] args) {
    sendRequest();
  }
  
  private static void sendRequest() {
    
    // Get Order by UUID (GET )
    
    try {
      
      // Create request
      Content content = Request.Get("http://[TT LAN IP]:8000/api/v1/orders/4d033706-a736-459e-9db0-3727b89c198b")
      
      // Add headers
      .addHeader("Authorization", "Basic MGE5YWViNDQtNjU0Yy00NGRjLWFhMjYtNjA5YWQzMTg2NTRkOg==")
      .addHeader("Content-Type", "application/json")
      
      // Fetch request and return content
      .execute().returnContent();
      
      // Print content
      System.out.println(content);
    }
    catch (IOException e) { System.out.println(e); }
  }
}
// Get Order by UUID (GET http://10.0.1.2:8000/api/v1/orders/4d033706-a736-459e-9db0-3727b89c198b)

NSURL* URL = [NSURL URLWithString:@"http://[TT LAN IP]:8000/api/v1/orders/4d033706-a736-459e-9db0-3727b89c198b"];
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:URL];
request.HTTPMethod = @"GET";

// Headers

[request addValue:@"Basic MGE5YWViNDQtNjU0Yy00NGRjLWFhMjYtNjA5YWQzMTg2NTRkOg==" forHTTPHeaderField:@"Authorization"];
[request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];

// Connection

NSURLConnection* connection = [NSURLConnection connectionWithRequest:request delegate:nil];
[connection start];
curl -X "GET" "http://[TT LAN IP]:8000/api/v1/orders/4d033706-a736-459e-9db0-3727b89c198b" \
	-H "Authorization: Basic MGE5YWViNDQtNjU0Yy00NGRjLWFhMjYtNjA5YWQzMTg2NTRkOg==" \
	-H "Content-Type: application/json"
# Install the Python Requests library:
# `pip install requests`

import requests

def send_request():
    # Get Order by UUID (GET http://[TT LAN IP]:8000/api/v1/orders/4d033706-a736-459e-9db0-3727b89c198b)

    try:
        r = requests.get(
            url="http://[TT LAN IP]:8000/api/v1/orders/4d033706-a736-459e-9db0-3727b89c198b",
            headers = {
                "Authorization":"Basic MGE5YWViNDQtNjU0Yy00NGRjLWFhMjYtNjA5YWQzMTg2NTRkOg==",
                "Content-Type":"application/json",
            },
        )
        print('Response HTTP Status Code : {status_code}'.format(status_code=r.status_code))
        print('Response HTTP Response Body : {content}'.format(content=r.content))
    except requests.exceptions.RequestException as e:
        print('HTTP Request failed')

Response 200 (application/json)

{
  "status": 200,
  "order": {
    "locationName": null,
    "orderLocated": null,
    "uuid": "9e1da5eb-59ea-4003-9c1c-15160879c88d",
    "orderCleared": "2014-08-21T10:00:41+00:00",
    "orderType": "ON_PREMISE",
    "orderStarted": "2014-08-21T10:00:36+00:00",
    "type": "ORDER_SUMMARY",
    "name": "66"
  }
}

Response 400 (application/json)

Returns if uuid is invalid.

{
  "status": 400,
  "message": "Invalid UUID. Must be in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX."
}