Table of Contents

Servers

URLDescription
http://GO-XXXXXXX/api/v1

Paths

GET /api/v1/version

Get the device firmware version

Responses

▶ 200 - Object with version property with firmware string value
application/json
NameTypeDescriptionAccepted values
version (required)stringAny

GET /api/v1/general

Get general settings of the device

Responses

▶ 200 - Response is an object with keys 'name', 'password', 'webURL'.
application/json
NameTypeDescriptionAccepted values
namestringa user defined name for the deviceAny
passwordstringa REST API password for Basic access authentication where the username is ignoredAny
webURLstring(advanced) a user defined URL serving custom HTML/JS to control the PI2cAny

POST /api/v1/general

Update the General settings of the PI2c device. Existing values are used for properties not sent.

Request body

application/json
NameTypeDescriptionAccepted values
namestringa user defined name for the deviceAny
passwordstringa REST API password for Basic access authentication where the username is ignoredAny
webURLstring(advanced) a user defined URL serving custom HTML/JS to control the PI2cAny
Example (generated)
{
  "name": "string",
  "password": "string",
  "webURL": "string"
}

Responses

▶ 200 - Object with success of storing the instructions set
application/json
NameTypeDescriptionAccepted values
success (required)booleanAny
error--Common Error object among all requestsAny
error.code (required)integerNumber to identify the error for tracking purposesAny
error.message (required)stringInformation describing what caused the errorAny
▶ default - Invalid packet, credentials, or some unexpected error
application/json
NameTypeDescriptionAccepted values
code (required)integerNumber to identify the error for tracking purposesAny
message (required)stringInformation describing what caused the errorAny

POST /api/v1/instr/exec

Run instructions. All of the instructions can be found in schemas below.

Request body

application/json
NameTypeDescriptionAccepted values
bodyarray

Array of instructions. Each instruction is an object with a key, 'func' whose value is the name of the function. It also may contain keys 'arg1', 'arg2', 'arg3' and associated values corresponding to arguments for the function.

Any
Example (generated)
[
  {
    "func": "open",
    "arg1": 1,
    "arg2": "INPUT",
    "arg3": "PULL_UP"
  }
]

Responses

▶ 200 - Response object with stats and success of instructions
application/json
NameTypeDescriptionAccepted values
success (required)booleanAll of the instructions succeeded or false if any failed or did not executeAny
beginTime (required)stringDate and time of when set began to executeAny
completeTime (required)stringDate and time of when set finished executingAny
instructions (required)array(object)Any
instructions.success (required)booleanInstruction succeeded or notAny
instructions.index (required)integerArray index from requested Instructions arrayAny
instructions.returnValue--

If instruction retrieved data, this will contain one of data of types listed below based on the output type specified by the instruction. For example a base64 string representing a buffer of 8-bit data, a utf-8 string, or a number.

Any
instructions.returnValue.0stringAny
instructions.returnValue.1numberAny
instructions.errorstringMessage possibly describing why instruction failed to executeAny
▶ default - Invalid packet, credentials, or some unexpected error
application/json
NameTypeDescriptionAccepted values
code (required)integerNumber to identify the error for tracking purposesAny
message (required)stringInformation describing what caused the errorAny

GET /api/v1/instr/stored

Get names of all stored instruction sets

Responses

▶ 200 - Successfully retreived a list of stored instruction set names
application/json
NameTypeDescriptionAccepted values
Responsearray(string)Array of names of each instruction setAny
▶ default - Invalid packet, credentials, or some unexpected error
application/json
NameTypeDescriptionAccepted values
code (required)integerNumber to identify the error for tracking purposesAny
message (required)stringInformation describing what caused the errorAny

GET /api/v1/instr/stored/{InstructionSetName}

Get instructions for given set name

Path parameters

InstructionSetName

Name of stored instruction set to retreive.

NameTypeInDescriptionAccepted values
InstructionSetName (required)stringpath

Name of stored instruction set to retreive.

Any

Responses

▶ 200 - A List of instructions that are stored for requested name
application/json
NameTypeDescriptionAccepted values
Responsearray

Array of instructions. Each instruction is an object with a key, 'func' whose value is the name of the function. It also may contain keys 'arg1', 'arg2', 'arg3' and associated values corresponding to arguments for the function.

Any
▶ default - Invalid packet, credentials, or some unexpected error
application/json
NameTypeDescriptionAccepted values
code (required)integerNumber to identify the error for tracking purposesAny
message (required)stringInformation describing what caused the errorAny

POST /api/v1/instr/stored/{InstructionSetName}

Store instructions. This is useful so that you can later execute a sequence of instructions with a simple name.

Path parameters

InstructionSetName

Name of stored instruction set to store/save. When successfully added the special set with name 'initialize' will automatically be run every time the device starts up.

NameTypeInDescriptionAccepted values
InstructionSetName (required)stringpath

Name of stored instruction set to store/save. When successfully added the special set with name 'initialize' will automatically be run every time the device starts up.

Any

Request body

application/json
NameTypeDescriptionAccepted values
bodyarray

Array of instructions. Each instruction is an object with a key, 'func' whose value is the name of the function. It also may contain keys 'arg1', 'arg2', 'arg3' and associated values corresponding to arguments for the function.

Any
Example (generated)
[
  {
    "func": "open",
    "arg1": 1,
    "arg2": "INPUT",
    "arg3": "PULL_UP"
  }
]

Responses

▶ 200 - Object with success of storing the instructions set
application/json
NameTypeDescriptionAccepted values
success (required)booleanAny
error--Common Error object among all requestsAny
error.code (required)integerNumber to identify the error for tracking purposesAny
error.message (required)stringInformation describing what caused the errorAny
▶ default - Invalid packet, credentials, or some unexpected error
application/json
NameTypeDescriptionAccepted values
code (required)integerNumber to identify the error for tracking purposesAny
message (required)stringInformation describing what caused the errorAny

POST /api/v1/instr/stored/{InstructionSetName}/exec

Execute named instruction set

Path parameters

InstructionSetName

Name of stored instruction set to execute

NameTypeInDescriptionAccepted values
InstructionSetName (required)stringpath

Name of stored instruction set to execute

Any

Responses

▶ 200 - Response object with stats and success of each instruction
application/json
NameTypeDescriptionAccepted values
success (required)booleanAll of the instructions succeeded or false if any failed or did not executeAny
beginTime (required)stringDate and time of when set began to executeAny
completeTime (required)stringDate and time of when set finished executingAny
instructions (required)array(object)Any
instructions.success (required)booleanInstruction succeeded or notAny
instructions.index (required)integerArray index from requested Instructions arrayAny
instructions.returnValue--

If instruction retrieved data, this will contain one of data of types listed below based on the output type specified by the instruction. For example a base64 string representing a buffer of 8-bit data, a utf-8 string, or a number.

Any
instructions.returnValue.0stringAny
instructions.returnValue.1numberAny
instructions.errorstringMessage possibly describing why instruction failed to executeAny
▶ default - Invalid packet, credentials, or some unexpected error
application/json
NameTypeDescriptionAccepted values
code (required)integerNumber to identify the error for tracking purposesAny
message (required)stringInformation describing what caused the errorAny

GET /api/v1/instr/stored/{InstructionSetName}/log

Get latest response for instruction set with given name when it last executed

Path parameters

InstructionSetName

Name of stored instruction set's response log to retreive

NameTypeInDescriptionAccepted values
InstructionSetName (required)stringpathName of stored instruction set's response log to retreiveAny

Responses

▶ 200 - Object Response per each instruction
application/json
NameTypeDescriptionAccepted values
hasLog (required)boolean

Has this stored instruction set executed. If so, the log key will be present with the response of the last execution.

Any
logobject

Object describing success and information of Instructions execution. It also contains an instructions key whose value is every instructions success status and returned data if applicapable. When a stored instruction set is executed the latest response object will be stored in it's corresponding log.

Any
log.success (required)booleanAll of the instructions succeeded or false if any failed or did not executeAny
log.beginTime (required)stringDate and time of when set began to executeAny
log.completeTime (required)stringDate and time of when set finished executingAny
log.instructions (required)array(object)Any
log.instructions.success (required)booleanInstruction succeeded or notAny
log.instructions.index (required)integerArray index from requested Instructions arrayAny
log.instructions.returnValue--

If instruction retrieved data, this will contain one of data of types listed below based on the output type specified by the instruction. For example a base64 string representing a buffer of 8-bit data, a utf-8 string, or a number.

Any
log.instructions.returnValue.0stringAny
log.instructions.returnValue.1numberAny
log.instructions.errorstringMessage possibly describing why instruction failed to executeAny
error--Common Error object among all requestsAny
error.code (required)integerNumber to identify the error for tracking purposesAny
error.message (required)stringInformation describing what caused the errorAny
▶ default - Invalid packet, credentials, or some unexpected error
application/json
NameTypeDescriptionAccepted values
code (required)integerNumber to identify the error for tracking purposesAny
message (required)stringInformation describing what caused the errorAny

Schemas

PI2c General Settings

NameTypeDescriptionAccepted values
namestringa user defined name for the deviceAny
passwordstringa REST API password for Basic access authentication where the username is ignoredAny
webURLstring(advanced) a user defined URL serving custom HTML/JS to control the PI2cAny
Example (generated)
{
  "name": "string",
  "password": "string",
  "webURL": "string"
}

Pin reset type

NameTypeDescriptionAccepted values
PinResetTypestringHow the pin is to be resetPIN_RESET, PIN_PRESERVE
Example (generated)
"PIN_RESET"

Poll Pin direction

NameTypeDescriptionAccepted values
PollPinDirectionstringCheck falling or rising edge or both when pollingPOLL_LOW, POLL_HIGH, POLL_BOTH
Example (generated)
"POLL_LOW"

Pin

NameTypeDescriptionAccepted values
PinnumberGPIO Pin number1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18
Example (generated)
1

Pin Mode

NameTypeDescriptionAccepted values
PinModestringSet whether GPIO Pin is input, output, or pwm if capableINPUT, OUTPUT, PWM
Example (generated)
"INPUT"

Pullup

NameTypeDescriptionAccepted values
PinInputModePullupstringPin Pullup in input modePULL_UP, PULL_DOWN, PULL_OFF
Example (generated)
"PULL_UP"

Pin Value

NameTypeDescriptionAccepted values
PinOutputModeValuestringPin string value in output modeHIGH, LOW
Example (generated)
"HIGH"

Pin Numerical Value

NameTypeDescriptionAccepted values
PinOutputNumModeValuenumberPin numerical value in output mode1, 0
Example (generated)
1

led

NameTypeDescriptionAccepted values
func (required)stringInstruction function nameled
arg1 (required)string

Which led (red or green). Note on startup when device is ready, red led will turn on for a second.

red, green
arg2 (required)--Any
arg2.0stringHIGH, LOW
arg2.1number1, 0
Example (generated)
{
  "func": "led",
  "arg1": "red",
  "arg2": "HIGH"
}

open

NameTypeDescriptionAccepted values
func (required)stringInstruction function nameopen
arg1 (required)numberGPIO Pin number1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18
arg2 (required)stringSet whether GPIO Pin is input, output, or pwm if capableINPUT, OUTPUT, PWM
arg3--Any
arg3.0stringPULL_UP, PULL_DOWN, PULL_OFF
arg3.1stringHIGH, LOW
Example (generated)
{
  "func": "open",
  "arg1": 1,
  "arg2": "INPUT",
  "arg3": "PULL_UP"
}

stored

NameTypeDescriptionAccepted values
func (required)stringInstruction function namestored
arg1 (required)stringName of stored instruction set to executeAny
Example (generated)
{
  "func": "stored",
  "arg1": "string"
}

mode

NameTypeDescriptionAccepted values
func (required)stringInstruction function namemode
arg1 (required)numberGPIO Pin number1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18
arg2 (required)stringSet whether GPIO Pin is input, output, or pwm if capableINPUT, OUTPUT, PWM
Example (generated)
{
  "func": "mode",
  "arg1": 1,
  "arg2": "INPUT"
}

read

NameTypeDescriptionAccepted values
func (required)stringInstruction function nameread
arg1 (required)numberGPIO Pin number1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18
Example (generated)
{
  "func": "read",
  "arg1": 1
}

readBuf

NameTypeDescriptionAccepted values
func (required)stringInstruction function namereadBuf
arg1 (required)numberGPIO Pin number1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18
arg2 (required)integerNumber of bits to readAny
Example (generated)
{
  "func": "readBuf",
  "arg1": 1,
  "arg2": 1
}

write

NameTypeDescriptionAccepted values
func (required)stringInstruction function namewrite
arg1 (required)numberGPIO Pin number1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18
arg2 (required)--set the output of the pin using string or number typesAny
arg2.0stringHIGH, LOW
arg2.1number1, 0
Example (generated)
{
  "func": "write",
  "arg1": 1,
  "arg2": "HIGH"
}

writeBuf

NameTypeDescriptionAccepted values
func (required)stringInstruction function namewriteBuf
arg1 (required)numberGPIO Pin number1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18
arg2 (required)stringbase64 encoded data to be written. Each byte should be 1 or 0 to represent a bitAny
Example (generated)
{
  "func": "writeBuf",
  "arg1": 1,
  "arg2": "string"
}

pud

NameTypeDescriptionAccepted values
func (required)stringInstruction function namepud
arg1 (required)numberGPIO Pin number1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18
arg2 (required)stringPin Pullup in input modePULL_UP, PULL_DOWN, PULL_OFF
Example (generated)
{
  "func": "pud",
  "arg1": 1,
  "arg2": "PULL_UP"
}

pwmSetClockDivider

NameTypeDescriptionAccepted values
func (required)stringInstruction function namepwmSetClockDivider
arg1 (required)number

This is a power-of-two divisor of the base 19.2MHz rate, with a maximum value of 4096 (4.6875kHz).

Any
Example (generated)
{
  "func": "pwmSetClockDivider",
  "arg1": 1
}

pwmSetRange

NameTypeDescriptionAccepted values
func (required)stringInstruction function namepwmSetRange
arg1 (required)number16, 18
arg2 (required)numberset rangeAny
Example (generated)
{
  "func": "pwmSetRange",
  "arg1": 16,
  "arg2": 1
}

pwmSetData

NameTypeDescriptionAccepted values
func (required)stringInstruction function namepwmSetData
arg1 (required)number16, 18
arg2 (required)numberset dataAny
Example (generated)
{
  "func": "pwmSetData",
  "arg1": 16,
  "arg2": 1
}

i2cBegin

NameTypeDescriptionAccepted values
func (required)stringAssign GPIO pins 1 and 3 to use i2ci2cBegin
Example (generated)
{
  "func": "i2cBegin"
}

i2cSetSlaveAddress

NameTypeDescriptionAccepted values
func (required)stringInstruction function namei2cSetSlaveAddress
arg1 (required)numberConfigure the slave address. This is between 0 - 0x7fAny
Example (generated)
{
  "func": "i2cSetSlaveAddress",
  "arg1": 0
}

i2cSetBaudRate

NameTypeDescriptionAccepted values
func (required)stringInstruction function namei2cSetBaudRate
arg1 (required)numberThe i2c baudrateAny
Example (generated)
{
  "func": "i2cSetBaudRate",
  "arg1": 1000
}

i2cRead

NameTypeDescriptionAccepted values
func (required)stringInstruction function namei2cRead
arg1 (required)numberNumber of bytes to readAny
Example (generated)
{
  "func": "i2cRead",
  "arg1": 1
}

i2cWrite

NameTypeDescriptionAccepted values
func (required)stringInstruction function namei2cWrite
arg1 (required)stringbase64 representation of bytes to writeAny
Example (generated)
{
  "func": "i2cWrite",
  "arg1": "string"
}

i2cUpdateReg

NameTypeDescriptionAccepted values
func (required)stringInstruction function namei2cUpdateReg
arg1 (required)stringn-byte register valueAny
arg2 (required)stringMask - to 4 byte mask value base64. Num bytes should be equal to valueAny
arg3 (required)stringValue - up to 4 byte data value base64. Num bytes should be equal to maskAny
Example (generated)
{
  "func": "i2cUpdateReg",
  "arg1": "stri",
  "arg2": "string",
  "arg3": "string"
}

i2cEnd

NameTypeDescriptionAccepted values
func (required)stringInstruction function namei2cEnd
Example (generated)
{
  "func": "i2cEnd"
}

spiBegin

NameTypeDescriptionAccepted values
func (required)stringInstruction function namespiBegin
Example (generated)
{
  "func": "spiBegin"
}

spiSetCSPolarity

NameTypeDescriptionAccepted values
func (required)stringInstruction function namespiSetCSPolarity
arg1 (required)stringHIGH
Example (generated)
{
  "func": "spiSetCSPolarity",
  "arg1": "HIGH"
}

spiSetClockDivider

NameTypeDescriptionAccepted values
func (required)stringInstruction function namespiSetClockDivider
arg1 (required)numberEven divisor of the base 250MHz rate ranging between 0 and 65536. If div is 128 set SPI speed to 1.95MHzAny
Example
{
  "func": "spiSetClockDivider",
  "arg1": 128
}

spiSetDataMode

NameTypeDescriptionAccepted values
func (required)stringInstruction function namespiSetDataMode
arg1 (required)number0=CPOL(0)CPHA(0),1=CPOL(0)CPHA(1),2=CPOL(1)CPHA(0),3=CPOL(1)CPHA(1)0, 1, 3
Example (generated)
{
  "func": "spiSetDataMode",
  "arg1": 0
}

spiTransfer

NameTypeDescriptionAccepted values
func (required)stringInstruction function namespiTransfer
arg1 (required)stringbase64 representation of bytes to writeAny
Example (generated)
{
  "func": "spiTransfer",
  "arg1": "string"
}

spiWrite

NameTypeDescriptionAccepted values
func (required)stringInstruction function namespiWrite
arg1 (required)stringbase64 representation of bytes to writeAny
Example (generated)
{
  "func": "spiWrite",
  "arg1": "string"
}

spiEnd

NameTypeDescriptionAccepted values
func (required)stringInstruction function namespiEnd
Example (generated)
{
  "func": "spiEnd"
}

sleep

NameTypeDescriptionAccepted values
func (required)stringInstruction function namesleep
arg1 (required)numbernumber of seconds to sleepAny
Example (generated)
{
  "func": "sleep",
  "arg1": 1
}

msleep

NameTypeDescriptionAccepted values
func (required)stringInstruction function namemsleep
arg1 (required)numberNumber of milliseconds to sleepAny
Example (generated)
{
  "func": "msleep",
  "arg1": 1
}

usleep

NameTypeDescriptionAccepted values
func (required)stringInstruction function nameusleep
arg1 (required)numberNumber of microseconds to sleepAny
Example (generated)
{
  "func": "usleep",
  "arg1": 100
}

Instructions

NameTypeDescriptionAccepted values
Instructionsarray

Array of instructions. Each instruction is an object with a key, 'func' whose value is the name of the function. It also may contain keys 'arg1', 'arg2', 'arg3' and associated values corresponding to arguments for the function.

Any
Example (generated)
[
  {
    "func": "open",
    "arg1": 1,
    "arg2": "INPUT",
    "arg3": "PULL_UP"
  }
]

Instruction Response

NameTypeDescriptionAccepted values
success (required)booleanInstruction succeeded or notAny
index (required)integerArray index from requested Instructions arrayAny
returnValue--

If instruction retrieved data, this will contain one of data of types listed below based on the output type specified by the instruction. For example a base64 string representing a buffer of 8-bit data, a utf-8 string, or a number.

Any
returnValue.0stringAny
returnValue.1numberAny
errorstringMessage possibly describing why instruction failed to executeAny
Example
{
  "success": true,
  "index": 0,
  "returnValue": "AAE="
}

Instructions Response

NameTypeDescriptionAccepted values
success (required)booleanAll of the instructions succeeded or false if any failed or did not executeAny
beginTime (required)stringDate and time of when set began to executeAny
completeTime (required)stringDate and time of when set finished executingAny
instructions (required)array(object)Any
instructions.success (required)booleanInstruction succeeded or notAny
instructions.index (required)integerArray index from requested Instructions arrayAny
instructions.returnValue--

If instruction retrieved data, this will contain one of data of types listed below based on the output type specified by the instruction. For example a base64 string representing a buffer of 8-bit data, a utf-8 string, or a number.

Any
instructions.returnValue.0stringAny
instructions.returnValue.1numberAny
instructions.errorstringMessage possibly describing why instruction failed to executeAny
Example (generated)
{
  "success": true,
  "beginTime": "2019-05-25T20:40:57Z",
  "completeTime": "2019-05-25T20:40:57Z",
  "instructions": [
    {
      "success": true,
      "index": 0,
      "returnValue": "AAE="
    }
  ]
}

Error

NameTypeDescriptionAccepted values
code (required)integerNumber to identify the error for tracking purposesAny
message (required)stringInformation describing what caused the errorAny
Example (generated)
{
  "code": 0,
  "message": "string"
}