Skip to content

Endpoint Configuration Reference

Joe Bellus edited this page Aug 13, 2017 · 2 revisions

Basic requests

The endpoint, at minimum, must specify a url and a request method.

{
     "url": "http://example.com/api/endpoint",
     "method": "GET"
}

Request parameters

Get requests can include query parameters seperately from the URL. This makes it easier to read and edit. The parameters will be encoded and appended into the url before the request.

{
     "url": "http://example.com/api/endpoint",
     "method": "GET",
     "data": {
         "pageSize": 20,
         "page": 1
     }
}

Post JSON payloads

You can post a JSON payload using the data node. It will be serialized and sent with the request.

{
     "url": "http://example.com/api/endpoint",
     "method": "POST",
     "data": {
         "attributes": {
              "name": "my_name"
         } 
     }
}

Specifying headers

You can specify custom headers that are set on the request.

{
     "url": "http://example.com/api/endpoint",
     "method": "POST",
     "headers": {
           "Content-Type": "application/json"
     },
     "data": {
         "attributes": {
              "name": "my_name"
         } 
     }
}

OnComplete scripts

You can execute a script once the request completes. This script is given access to all the details for the request and response. Multiple scripts can be given and each will be executed. For more information on scripting check the Scripting Reference.

{
     "url": "http://example.com/api/endpoint",
     "method": "POST",
     "headers": {
           "Content-Type": "application/json"
     },
     "onComplete": ["processResponse"],
     "data": {
         "attributes": {
              "name": "my_name"
         } 
     }
}

Transformation scripts

Scripts can be used to modify the request before it is sent to the server. This is useful for more complicated requests, like ones requiring authentication tokens, or dynamic data like a current time. Multiple scripts can be given and each will be executed. For more information on scripting check the Scripting Reference.

{
     "url": "http://example.com/api/endpoint",
     "method": "POST",
     "headers": {
           "Content-Type": "application/json"
     },
     "transform": ["addData", "addAuth"],
     "data": {
         "attributes": {
              "name": "my_name"
         } 
     }
}

Variable expansion

Variables defined in the global or local config can be used in the endpoint definition. They can be included in the url, request method, query params, or post data.

{
     "url": "http://$host/api/endpoint",
     "method": "POST",
     "data": {
         "attributes": {
              "name": "$name"
         } 
     }
}

Fake data generation

Randomized fake data can be included in the url, query params, or post data using a #{key} value. This will be expanded to a specific type of string data based on the key passed.

{
     "url": "http://$host/api/endpoint",
     "method": "POST",
     "data": {
         "attributes": {
              "name": "#{fullName}",
              "phone": "#{phone}",
              "email": "#{email}",
         } 
     }
}

Currently supported data keys are:

  • city
  • color
  • country
  • email
  • femaleFirstName
  • femaleFullName
  • maleFirstName
  • maleFullName
  • firstName
  • lastName
  • fullName
  • gender
  • hexColor
  • ip
  • industry
  • jobtitle
  • month
  • monthNum
  • monthShort
  • phone
  • product
  • productName
  • street
  • streetAddress
  • weekDay
  • zip