1. Request Header
  2. Request Body
  3. Example
  4. Response
  5. Encoding

Analyzing data

The WarpScript™ data manipulation language can be used using a Warp 10™ API. This API is served by the egress component, also referred to as the Warp 10™ Analytics Engine.

The HTTP endpoint used by the WarpScript™ API is https://HOST:PORT/api/vX/exec, where HOST:PORT is a valid endpoint for the public Warp 10™ API and vX is the version of the API you want to use (currently v0).

The WarpScript™ API must be accessed using the POST method.

Request Header

No special headers are required. See Encoding below if needed.

Request Body

The request body contains the WarpScript™ code to execute.

Example

POST /api/v0/exec HTTP/1.1
Host: host

//
// This is WarpScript code fragment
//

// Egress token to use
'TOKEN_VALUE' 'token' STORE

[
  $token                          // read token
  '~class.*'                      // Class name selector
  { 'foo' '=bar' }                // Labels selector
  '2013-01-01T00:00:00.000000Z'   // start timestamp
  '2014-01-01T00:00:00.000000Z'   // end timestamp
]
FETCH

Response

The response body contains a JSON array whose elements are the different levels of the WarpScript™ stack after the execution has terminated, the first element being the top of the stack.

Elements which cannot be represented in JSON (such as functions) will be represented as null.

Response headers will indicate the number of datapoints fetched from the Warp 10™ Storage Engine, the number of WarpScript™ operations performed, the time spent executing the code and some error related information when an error was encountered.

Encoding

When you send non ASCII WarpScript to exec endpoint, make sure you specify encoding in your request headers.

  • For non compressed requests, add Content-Type: text/plain; charset=UTF-8 header to your request.
  • For gzipped requests, Warp 10 assumes the WarpScript is UTF-8 encoded. The JSON response is always UTF-16 encoded, with \uXXXX escapes.

Examples with curl on a UTF-8 platform:

curl --data-binary "'é' DUP SIZE" -H "Content-Type: text/plain; charset=UTF-8"  https://warp.senx.io/api/v0/exec
[1,"\u00e9"]

00e9 is the UTF-16 for 'é'. 'é' is considered as one symbol, string length = 1.

curl --data-binary "'é' DUP SIZE" https://warp.senx.io/api/v0/exec 
[2,"\u00c3\u00a9"]

c3a9 is the UTF-8 representation for 'é'. 'é' is considered by Warp 10 as two different symbols, string length = 2.

echo "'é' DUP SIZE" |gzip -c | curl -T - -H "Content-Type: application/gzip" https://warp.senx.io/api/v0/exec 
[1,"\u00e9"]%                      

The gzip decompression assumes the input is utf-8 encoded. Extra headers will be ignored.

WarpStudio and VSCode do the encoding and decoding job for you, see WarpScript Tooling.