HTTP

API Reference

Basics

Welcome

Get information about the Flexio API:

curl -X GET 'https://www.flex.io/api/v1/about'

Welcome to the Flexio API!

With the Flexio API, you can build, save, and invoke sequences of tasks, called pipes, that take input, process it, and return an output.

You can define and use pipes inline in your code, or you can define and save them in one place and then invoke them repeatedly with different sets of parameters elsewhere.

You can share your pipes with others, allowing them to invoke these pipes with parameters they supply, giving you the ability to quickly create cloud functions for use by you and others.

You can also define pipes that use connections that let you read and write to various cloud services while keeping credentials to these hidden.

We hope you enjoy getting some serious stuff done! And having lot’s of fun.

Base URL

The base URL for all API requests is: https://www.flex.io/api/v1

Versioning

The API version is included in the base URL of the request. The current version is ‘v1’.

Authentication

Get information about yourself:

curl -X GET 'https://www.flex.io/api/v1/users/me'
--header "Authorization: Bearer {token}"

The Flex.io API uses Bearer Authentication. API requests must be made over HTTPS and authenticated by supplying an api key in the token portion of an HTTP Authorization header: Authorization: Bearer {token}

To get your API key:

  1. Create an account
  2. Log in to your account
  3. Copy the API key from the Dashboard page

Alternatively, you can get and create API keys in your user account area in the API section:

  1. Create an account
  2. Log in to your account
  3. Go to your account information by clicking on your avatar in the upper right
  4. In the account area, go to the API tab
  5. Copy your API key, or “Create API Key” to creat a new API key

Once you have your API key, you can try a basic request to return your user information:

  1. Create an HTTP GET request to https://www.flex.io/api/v1/users/me
  2. Set the HTTP Authorization header, using your api key instead of the placeholder: “Authorization: Bearer {token}”
  3. Make the request

Requests

Creating a pipe:

curl -X POST 'https://www.flex.io/api/v1/pipes/'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"name": "Github Progress",
"description": "Monitor status for a variety of projects on Github"
}
'
Flexio.pipe()
.save({
name: "Github Progress",
description: "Monitor status for a variety of projects on Github"
})

Getting a pipe:

curl -X GET 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"
Flexio.pipe().load('{id}')

Updating a pipe:

curl -X POST 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"name": "Github Commits",
"description": "Monitor commits for projects on GitHub"
}
'
Flexio.pipe()
.load('{id}')
.save({
name: "Github Commits",
description: "Monitor commits for projects on GitHub"
})

Deleting a pipe:

curl -X DELETE 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"

Basic Concepts

The Flex.io API is organized around REST: pipes, connections, and other resources are accessed with URL endpoints and manipulated using HTTP GET, POST, and DELETE verbs. GET is used for reading resources, POST is used for creating and updating resources, and DELETE is used for deleting resources.

In general, resources identifiers are specified in the URL. In cases where objects are being created or updated, additional parameters are sent in the request body.

When reading, updating, or deleting existing resources, resource identifiers are specified in the URL.

Headers

When making all requests, the authorization header must be set and include the api key in the token portion of the authorization header: Authorization: Bearer {token}

In addition, when making requests that create or update a resource, parameters are sent as JSON in the POST request and the content type header must be set to the JSON content type: Content-Type: application/json

Cross Origin Sharing

The Flex.io supports Cross Origin Resource Sharing (CORS), so you can make requests from any location.

Rate Limits

If you exceed your rate limitations, you’ll get a rate limit error. We expect you won’t encounter rate limits in normal usage.

Responses

Basic Concepts

In most cases, responses are returned as JSON, and the HTTP status code indicates success or failure. In general, response codes in the 200-level range indicate success, response codes in the 400-level range indicate a failure caused by a request that can’t be fulfilled even though the Flex.io service is working as expected, and response codes in the 500-level range indicate a failure caused by a problem with the Flex.io service itself.

HTTP status codes have the following meanings:

Code Meaning
200 OK
400 Bad request
401 Unauthorized
403 Forbidden
404 Not found
422 Unprocessable entity
500 Internal server error

Errors

When a response indicates a failure with an HTTP status code, the body of the response will contain an error object with additional information about the error. The error object contains at least two parameters: a code that indicates the type of error and a message that provides a description of the error.

For example, if you make the following request to an invalid API endpoint, you’ll get an error object that indicates an invalid request:

GET https://www.flex.io/api/v1/invalid-endpoint

{
"error": {
"code": "invalid_request",
"message": "Invalid request"
}
}

Following are a list of the error codes:

Code Description
general General problem that doesn’t have more specific information
unimplemented A request is made contains a feature that isn’t implemented
deprecated A request is made for a feature that is deprecated
invalid-version A request is made that isn’t for a valid API version
invalid-request A request is made on an API endpoint that isn’t available
invalid-syntax A request is made with syntax that isn’t valid
missing-parameter A request doesn’t contain a parameter that’s needed
invalid-parameter A request contains a parameter that’s in the wrong format
unauthorized A request is made for a resource that isn’t public, and the request doesn’t have any authorization information to check the access rights
insufficient-rights A request is made for a resource that isn’t public, and the request isn’t authorizated to access the resource
rate-limit-exceeded A request is made that exceeds the rate limit
size-limit-exceeded A request is made that exceeds the size limit
integrity-failed An operation involves an integrity check, and the entity being checked fails to match a supplied integrity check value
connection-failed An operation involves making a connection, but the process of connecting fails
create-failed An operation involves creating something, but the process of creating it fails
read-failed An operation involves reading something, but the process of reading it fails
write-failed An operation involves writing to something, but the process of writing to it fails
delete-failed An operation involves deleting something, but the process of deleting it fails
no-database Server error indicating a database isn’t available
no-model Server error indicating a model isn’t available
no-service Server error indicating a service isn’t available
no-object Server error indicating an object isn’t available

Pagination

Requests returning lists of items will return all the items in the list.

SDK and CLI

Overview

Flex.io has a Javascript SDK and a CLI that make it easy to integrate the Flex.io service into your applications and workflow:

More Information

For more information about the Javascript SDK, see the Javscript SDK documentation.

More information about the CLI is coming soon!

Pipes

Overview

Pipes are made up a series of tasks that run sequentially. Pipe input is passed to the first task, then the output of that task is passed to the next task and so on, until the tasks are finished and the pipe returns the resulting output.

Pipes support a variety of different tasks. For example, pipes may include tasks that can execute Python or Javascript code, make requests from APIs directly or from connections that hide API credentials, as well as perform operations on data, such as converting from one format to another. We’ll see how to add tasks to pipes later as well as a complete list of what tasks are possible.

Once you’ve defined a pipe, you can save it with an identifier, and then invoke it as a cloud function with this identifier, passing it parameters you supply when invoking it. For example, you might create a pipe that you call ‘verified-content’ that takes POST parameters, takes these parameters and verifies them with a remotely defined and sha-checked python function, then POSTs the verified parameters to an API endpoint. Once you’ve defined this pipe and saved it, you can run this pipe using the ‘verified-content’ identifier and use it to pass parameters that are verified to the API endpoint.

GET /pipes

To get a list of pipes, use the following with your api key in place of the {token}:

curl -X GET 'https://www.flex.io/api/v1/pipes'
--header "Authorization: Bearer {token}"

Description

Gets a list of pipe objects

Response

Property Type Description
eid string auto-generated object identifier
eid_type string object type
eid_status string object status
ename string user-defined object identifier
name string pipe name
description string pipe description
owned_by object owner of the pipe
followed_by array users following the pipe
task array array of task objects making up the pipe logic
schedule object schedule information for when the pipe will run
schedule_status string schedule status indicating whether or not a pipe is scheduled; if the schedule status is ‘A’, the pipe is scheduled, and if the schedule status is ‘I’, then the pipe is unscheduled; if the schedule status is unspecified, it defaults to the unscheduled status
created string date when the object was created in ISO 8601 format
updated string date when the object was last updated in ISO 8601 format

[
{
"eid": "dw19t2qccp1h",
"eid_type": "PIP",
"eid_status": "A",
"ename": "my-custom-pipe-alias",
"name": "Flex.io Website",
"description": "Flex.io Website",
"owned_by": {
"eid": "h0cdcmy0g0xf",
"eid_type": "USR",
"user_name": "john",
"first_name": "John",
"last_name": "Bunyan",
"email_hash": "3959012ba8803f90f546396e802c9298"
},
"followed_by": [
],
"task": [
{
"type": "flexio.request",
"params": {
"url": "http://www.flex.io"
}
}
],
"schedule": {
},
"schedule_status": "I",
"created": "2017-02-10T20:18:26+0000",
"updated": "2017-03-02T04:41:17+0000"
}
]

POST /pipes

To create a new pipe, use the following with your api key in place of the {token}:

curl -X POST 'https://www.flex.io/api/v1/pipes'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"name": "Flexio Website",
"ename": "my-custom-pipe-alias",
"description": "Flex.io Website",
"task": [
{
"type": "flexio.request",
"params": {
"url": "https://www.flex.io"
}
}
]
}
'
Flexio.pipe()
.request('https://www.flex.io')
.save(function(err, result) {
console.log(result)
})

Description

Creates a pipe and returns the newly created pipe object with the pipe properties

Body Parameters

Property Type Description
eid_status string object status; if the status is ‘P’, it is pending and will not appear in the active list of pipes, but can still have it’s properties set; if the status is ‘A’, it is active and will appear in the list of pipes; if the status is ‘T’ it is trashed and will appear in the list of trashed items; if the status is ‘D’, it is deleted and will not appear in any list
ename string user-defined object identifier; if the ename is specified, it must be a globally unique, and valid string; to avoid nameclashes, we recommend you use your username as a prefix for enames you choose
name string pipe name
description string pipe description
task array array of tasks making up the pipe logic
schedule object schedule information for when the pipe will run
schedule_status string schedule status indicating whether or not a pipe is scheduled; if the schedule status is ‘A’, the pipe is scheduled, and if the schedule status is ‘I’, then the pipe is unscheduled; if the schedule status is unspecified, it defaults to the unscheduled status

Response

Property Type Description
eid string auto-generated object identifier
eid_type string object type
eid_status string object status
ename string user-defined object identifier
name string pipe name
description string pipe description
owned_by object owner of the pipe
followed_by array users following the pipe
task array array of task objects making up the pipe logic
schedule object schedule information for when the pipe will run
schedule_status string schedule status indicating whether or not a pipe is scheduled; if the schedule status is ‘A’, the pipe is scheduled, and if the schedule status is ‘I’, then the pipe is unscheduled; if the schedule status is unspecified, it defaults to the unscheduled status
created string date when the object was created in ISO 8601 format
updated string date when the object was last updated in ISO 8601 format

{
"eid": "dw19t2qccp1h",
"eid_type": "PIP",
"eid_status": "A",
"ename": "my-custom-pipe-alias",
"name": "Flex.io Website",
"description": "Flex.io Website",
"owned_by": {
"eid": "h0cdcmy0g0xf",
"eid_type": "USR",
"user_name": "john",
"first_name": "John",
"last_name": "Bunyan",
"email_hash": "3959012ba8803f90f546396e802c9298"
},
"followed_by": [
],
"task": [
{
"type": "flexio.request",
"params": {
"url": "https://www.flex.io"
}
}
],
"schedule": {
},
"schedule_status": "I",
"created": "2017-02-10T20:18:26+0000",
"updated": "2017-03-02T04:41:17+0000"
}

GET /pipes/{id}

To get information for a pipe, use the following with the eid or ename of the pipe in place of the {id} and your api key in place of the {token}:

curl -X GET 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"

Description

Gets a single pipe object

Path Parameters

Property Type Description
id string unique object identifier; either the auto-generated eid object identifier, or the user-defined ename object identifier

Response

Property Type Description
eid string auto-generated object identifier
eid_type string object type
eid_status string object status
ename string user-defined object identifier
name string pipe name
description string pipe description
owned_by object owner of the pipe
followed_by array users following the pipe
task array array of task objects making up the pipe logic
schedule object schedule information for when the pipe will run
schedule_status string schedule status indicating whether or not a pipe is scheduled; if the schedule status is ‘A’, the pipe is scheduled, and if the schedule status is ‘I’, then the pipe is unscheduled; if the schedule status is unspecified, it defaults to the unscheduled status
created string date when the object was created in ISO 8601 format
updated string date when the object was last updated in ISO 8601 format

{
"eid": "dw19t2qccp1h",
"eid_type": "PIP",
"eid_status": "A",
"ename": "my-custom-pipe-alias",
"name": "Flex.io Website",
"description": "Flex.io Website",
"owned_by": {
"eid": "h0cdcmy0g0xf",
"eid_type": "USR",
"user_name": "john",
"first_name": "John",
"last_name": "Bunyan",
"email_hash": "3959012ba8803f90f546396e802c9298"
},
"followed_by": [
],
"task": [
{
"type": "flexio.request",
"params": {
"url": "https://www.flex.io"
}
}
],
"schedule": {
},
"schedule_status": "I",
"created": "2017-02-10T20:18:26+0000",
"updated": "2017-03-02T04:41:17+0000"
}

POST /pipes/{id}

To update a pipe, use the following with the eid or ename of the pipe in place of the {id} and your api key in place of the {token}:

curl -X POST 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"name": "New Name",
"description": "New Description",
"task": [
]
}
'

Description

Updates a pipe with the specified values and returns the pipe object with the updated pipe properties

Path Parameters

Property Type Description
id string unique object identifier; either the auto-generated eid object identifier, or the user-defined ename object identifier

Body Parameters

Property Type Description
eid_status string object status; if the status is ‘P’, it is pending and will not appear in the active list of pipes, but can still have it’s properties set; if the status is ‘A’, it is active and will appear in the list of pipes; if the status is ‘T’ it is trashed and will appear in the list of trashed items; if the status is ‘D’, it is deleted and will not appear in any list
ename string user-defined object identifier; if the ename is specified, it must be a globally unique, and valid string; to avoid nameclashes, we recommend you use your username as a prefix for enames you choose
name string pipe name
description string pipe description
task array array of tasks making up the pipe logic
schedule object schedule information for when the pipe will run
schedule_status string schedule status indicating whether or not a pipe is scheduled; if the schedule status is ‘A’, the pipe is scheduled, and if the schedule status is ‘I’, then the pipe is unscheduled; if the schedule status is unspecified, it defaults to the unscheduled status

Response

Property Type Description
eid string auto-generated object identifier
eid_type string object type
eid_status string object status
ename string user-defined object identifier
name string pipe name
description string pipe description
owned_by object owner of the pipe
followed_by array users following the pipe
task array array of task objects making up the pipe logic
schedule object schedule information for when the pipe will run
schedule_status string schedule status indicating whether or not a pipe is scheduled; if the schedule status is ‘A’, the pipe is scheduled, and if the schedule status is ‘I’, then the pipe is unscheduled; if the schedule status is unspecified, it defaults to the unscheduled status
created string date when the object was created in ISO 8601 format
updated string date when the object was last updated in ISO 8601 format

{
"eid": "dw19t2qccp1h",
"eid_type": "PIP",
"eid_status": "A",
"ename": "my-custom-pipe-alias",
"name": "New Name",
"description": "New Description",
"owned_by": {
"eid": "h0cdcmy0g0xf",
"eid_type": "USR",
"user_name": "john",
"first_name": "John",
"last_name": "Bunyan",
"email_hash": "3959012ba8803f90f546396e802c9298"
},
"followed_by": [
],
"task": [
],
"schedule": {
},
"schedule_status": "I",
"created": "2017-02-10T20:18:26+0000",
"updated": "2017-03-02T04:41:17+0000"
}

DELETE /pipes/{id}

To delete a pipe, use the following with the eid or ename of the pipe in place of the {id} and your api key in place of the {token}:

curl -X DELETE 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"

Description

Deletes the pipe and returns basic identifier and status information for the pipe that was deleted

Path Parameters

Property Type Description
id string unique object identifier; either the auto-generated eid object identifier, or the user-defined ename object identifier

Response

Property Type Description
eid string auto-generated object identifier
eid_type string object type
eid_status string object status

{
"eid": "dw19t2qccp1h",
"eid_type": "PIP",
"eid_status": "D"
}

POST /pipes/{id}/run

To run a pipe, use the following with the eid or ename of the pipe in place of the {id}, your api key in place of the {token}, and any data you want to pass to the pipe when it runs:

curl -X POST 'https://www.flex.io/api/v1/pipes/{id}/run'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"param1": "value1",
"param2": "value2",
...
}
'

Description

Runs a pipe, processing any data that’s posted with the logic specified in the pipe, and returning the results of the process

Path Parameters

Property Type Description
id string unique object identifier; either the auto-generated eid object identifier, or the user-defined ename object identifier

Body Parameters

Property Type Description
data string in addition to the basic identifier information, any other form data can be posted to the pipe for processing; this data can be used for both controlling how the pipe runs as well as the data itself that the pipe processes

Response

The response is the user-defined output of the pipe. For example, if the pipe echos ‘Hello, world!’ to stdout in the pipe logic, then the result will be ‘Hello, world!’.

Connections

Overview

Connections are collections of information about a resource, such as an API, that can be used by pipes when making requests. This information may include base API URL endpoints, header information such as user agent or content type, or API tokens that are needed to access the API.

Connections allow pipes to define and make HTTP requests using the connection info without exposing API tokens, and without having to define the connection info each time a request is defined in the pipe.

GET /connections

To get a list of connections, use the following with your api key in place of the {token}:

curl -X GET 'https://www.flex.io/api/v1/connections'
--header "Authorization: Bearer {token}"

Description

Gets a list of connection objects

Response

Property Type Description
eid string auto-generated object identifier
eid_type string object type
eid_status string object status
ename string user-defined object identifier
name string connection name
description string connection description
connection_type string type of connection
connection_status string status of the connection
connection_info object connection info associated with the connection
expires string expiration date of the connection
owned_by object owner of the connection
followed_by array users following the connection
created string date when the object was created in ISO 8601 format
updated string date when the object was last updated in ISO 8601 format

[
{
"eid": "zw62t4qxcpmr",
"eid_type": "CTN",
"eid_status": "A",
"ename": "my-custom-connection-alias",
"name": "HTTP Connection",
"description": "HTTP Connection to API",
"connection_type": "http",
"connection_status": "A",
"connection_info": {
"url": "https://api.service.com/endpoint",
"headers": {
"Authorization": "Bearer :token",
"Content-Type": "application/json"
}
},
"expires": "",
"owned_by": {
"eid": "h0cdcmy0g0xf",
"eid_type": "USR",
"user_name": "john",
"first_name": "John",
"last_name": "Bunyan",
"email_hash": "3959012ba8803f90f546396e802c9298"
},
"followed_by": [
],
"created": "2017-02-10T20:18:26+0000",
"updated": "2017-03-02T04:41:17+0000"
}
]

POST /connections

To create a new connection, use the following with your api key in place of the {token}:

curl -X POST 'https://www.flex.io/api/v1/connections'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"name": "HTTP Connection",
"description": "HTTP Connection to API",
"connection_type": "http",
"connection_info": {
"url": "https://api.service.com/endpoint",
"headers": {
"Authorization": "Bearer :token",
"Content-Type": "application/json"
}
}
}
'

Description

Creates a new connection and returns the newly created connection object

Body Parameters

Property Type Description
eid_status string object status; if the status is ‘P’, it is pending and will not appear in the active list of connections, but can still have it’s properties set; if the status is ‘A’, it is active and will appear in the list of connections; if the status is ‘T’ it is trashed and will appear in the list of trashed items; if the status is ‘D’, it is deleted and will not appear in any list
ename string user-defined object identifier; if the ename is specified, it must be a globally unique, and valid string; to avoid nameclashes, we recommend you use your username as a prefix for enames you choose
name string connection name
description string connection description
connection_type string connection type indicator; ‘http’ for HTTP connections
connection_status string connection status; if the connection is available, the connection status is ‘A’; if the connection is unavailable, the connection status is ‘U’; if the connection status has an error of some kind, the connection status is ‘E’
connection_info object information assoeicated with the connection; for example, for http connections, this will include the base url of the connection as well as http header information; when this connection is used in a pipe request, this connection info will be applied to the request being made in the pipe

Response

Property Type Description
eid string auto-generated object identifier
eid_type string object type
eid_status string object status
ename string user-defined object identifier
name string connection name
description string connection description
connection_type string type of connection
connection_status string status of the connection
connection_info object connection info associated with the connection
expires string expiration date of the connection
owned_by object owner of the connection
followed_by array users following the connection
created string date when the object was created in ISO 8601 format
updated string date when the object was last updated in ISO 8601 format

{
"eid": "zw62t4qxcpmr",
"eid_type": "CTN",
"eid_status": "A",
"ename": "my-custom-connection-alias",
"name": "HTTP Connection",
"description": "HTTP Connection to API",
"connection_type": "http",
"connection_status": "A",
"connection_info": {
"url": "https://api.service.com/endpoint",
"headers": {
"Authorization": "Bearer :token",
"Content-Type": "application/json"
}
},
"expires": "",
"owned_by": {
"eid": "h0cdcmy0g0xf",
"eid_type": "USR",
"user_name": "john",
"first_name": "John",
"last_name": "Bunyan",
"email_hash": "3959012ba8803f90f546396e802c9298"
},
"followed_by": [
],
"created": "2017-02-10T20:18:26+0000",
"updated": "2017-03-02T04:41:17+0000"
}

GET /connections/{id}

To get information for a connection, use the following with the eid or ename of the connection in place of the {id} and your api key in place of the {token}:

curl -X GET 'https://www.flex.io/api/v1/connections/{id}'
--header "Authorization: Bearer {token}"

Description

Gets a single connection object

Path Parameters

Property Type Description
id string unique object identifier; either the auto-generated eid object identifier, or the user-defined ename object identifier

Response

Property Type Description
eid string auto-generated object identifier
eid_type string object type
eid_status string object status
ename string user-defined object identifier
name string connection name
description string connection description
connection_type string type of connection
connection_status string status of the connection
connection_info object connection info associated with the connection
expires string expiration date of the connection
owned_by object owner of the connection
followed_by array users following the connection
created string date when the object was created in ISO 8601 format
updated string date when the object was last updated in ISO 8601 format

{
"eid": "zw62t4qxcpmr",
"eid_type": "CTN",
"eid_status": "A",
"ename": "my-custom-connection-alias",
"name": "HTTP Connection",
"description": "HTTP Connection to API",
"connection_type": "http",
"connection_status": "A",
"connection_info": {
"url": "https://api.service.com/endpoint",
"headers": {
"Authorization": "Bearer :token",
"Content-Type": "application/json"
}
},
"expires": "",
"owned_by": {
"eid": "h0cdcmy0g0xf",
"eid_type": "USR",
"user_name": "john",
"first_name": "John",
"last_name": "Bunyan",
"email_hash": "3959012ba8803f90f546396e802c9298"
},
"followed_by": [
],
"created": "2017-02-10T20:18:26+0000",
"updated": "2017-03-02T04:41:17+0000"
}

POST /connections/{id}

To update a connection, use the following with the eid or ename of the connection in place of the {id} and your api key in place of the {token}:

curl -X POST 'https://www.flex.io/api/v1/connections/{id}'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"name": "New Name",
"description": "New Description",
}
'

Description

Updates a connection with the specified values and returns the connection object with the updated connection properties

Path Parameters

Property Type Description
id string unique object identifier; either the auto-generated eid object identifier, or the user-defined ename object identifier

Body Parameters

Property Type Description
ename string user-defined object identifier; alternatively, a user-defined ‘ename’ can be specified in the {id} portion of the request path instead of an ‘eid’
name string connection name
description string connection description
connection_type string connection type indicator; ‘http’ for HTTP connections
connection_status string connection status; if the connection is available, the connection status is ‘A’; if the connection is unavailable, the connection status is ‘U’; if the connection status has an error of some kind, the connection status is ‘E’
connection_info object information assoeicated with the connection; for example, for http connections, this will include the base url of the connection as well as http header information; when this connection is used in a pipe request, this connection info will be applied to the request being made in the pipe

Response

Property Type Description
eid string auto-generated object identifier
eid_type string object type
eid_status string object status
ename string user-defined object identifier
name string connection name
description string connection description
connection_type string type of connection
connection_status string status of the connection
connection_info object connection info associated with the connection
expires string expiration date of the connection
owned_by object owner of the connection
followed_by array users following the connection
created string date when the object was created in ISO 8601 format
updated string date when the object was last updated in ISO 8601 format

{
"eid": "zw62t4qxcpmr",
"eid_type": "CTN",
"eid_status": "A",
"ename": "my-custom-connection-alias",
"name": "New Name",
"description": "New Description",
"connection_type": "http",
"connection_status": "A",
"connection_info": {
"url": "https://api.service.com/endpoint",
"headers": {
"Authorization": "Bearer :token",
"Content-Type": "application/json"
}
},
"expires": "",
"owned_by": {
"eid": "h0cdcmy0g0xf",
"eid_type": "USR",
"user_name": "john",
"first_name": "John",
"last_name": "Bunyan",
"email_hash": "3959012ba8803f90f546396e802c9298"
},
"followed_by": [
],
"created": "2017-02-10T20:18:26+0000",
"updated": "2017-03-02T04:41:17+0000"
}

DELETE /connections/{id}

To delete a connection, use the following with the eid or ename of the connection in place of the {id} and your api key in place of the {token}:

curl -X DELETE 'https://www.flex.io/api/v1/connections/{id}'
--header "Authorization: Bearer {token}"

Description

Deletes the connection and returns basic identifier and status information for the connection that was deleted

Path Parameters

Property Type Description
id string unique object identifier; either the auto-generated eid object identifier, or the user-defined ename object identifier

Response

Property Type Description
eid string auto-generated object identifier
eid_type string object type
eid_status string object status

{
"eid": "zw62t4qxcpmr",
"eid_type": "CTN",
"eid_status": "D"
}

Users

Overview

Users are the owners of pipes and connections they create. Users can share their pipes, allowing other users, called followers, to either read, write, or run these pipes, depending on the permissions they are granted. In the same way, users can share their pipes with the public.

GET /users/{id}

To get information for a user, use the following with the eid of the user you want to get in place of the {id} and your api key in place of the {token}; to get information for yourself, use ‘me’ for the {id}:

curl -X GET 'https://www.flex.io/api/v1/users/{id}'
--header "Authorization: Bearer {token}"

Description

Gets information about the user

Path Parameters

Property Type Description
id string unique object identifier; either the auto-generated eid object identifier, or the user-defined ename object identifier

Response

Property Type Description
eid string auto-generated object identifier
eid_type string object type
eid_status string object status
ename string user-defined object identifier
user_name string user name
first_name string first name
last_name string last name
email string user email
email_hash string MD5 hash of the email
phone string user phone number
location_city string city where user is located
location_state string state where user is located
location_country string country where user is located
company_name string name of the company where the user works
company_url string url of the company where the user works
locale_language string language preference for the user
locale_decimal string decimal preference for the user
locale_thousands string thousands separator preference for the user
locale_dateformat string data format preference for the user
timezone string timezone for the user
config string configuration settings
created string date when the object was created in ISO 8601 format
updated string date when the object was last updated in ISO 8601 format

{
"eid": "h0cdcmy0g0xf",
"eid_type": "USR",
"eid_status": "A",
"ename": "",
"user_name": "john",
"first_name": "John",
"last_name": "Bunyan",
"email": "john.bunyan@flex.io",
"email_hash": "3959012ba8803f90f546396e802c9298",
"phone": "",
"location_city": "",
"location_state": "",
"location_country": "",
"company_name": "",
"company_url": "",
"locale_language": "en_US",
"locale_decimal": ".",
"locale_thousands": ",",
"locale_dateformat": "m\/d\/Y",
"timezone": "UTC",
"config": {
"app.prompt.tour.shown": true
},
"created": "2017-02-10T20:18:26+0000",
"updated": "2017-06-13T15:56:50+0000"
}

Tasks

Convert

To add a convert task to a pipe that converts a delimited file to JSON, use the following:

curl -X POST 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"task": [{
"type": "flexio.convert",
"params": {
"input": {
"format": "delimited",
"delimiter": "{comma}",
"header": true,
"qualifier": "{none}"
},
"output": {
"format": ""
}
}
}]
}
'

Description

Converts the input from one format to another

Parameters

Property Type Description
input object format specifier for the input; the primary parameter for this object is ‘format’ and may be one of delimited, fixed, json, rss, pdf, table
output object format specifier for the output; the primary parameter for this object is ‘format’ and may be one of delimited, fixed, json, rss, pdf, table

{
"type": "flexio.convert",
"params": {
"input": {
"format": "delimited",
"delimiter": "{comma}",
"header": true,
"qualifier": "{none}"
},
"output": {
"format": ""
}
}
}

Returns

Returns the converted input

Echo

To add an echo task to a pipe that writes ‘Hello, World!’ to the output, use the following:

curl -X POST 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"task": [{
"type": "flexio.echo",
"params": {
"msg": "Hello, World!"
}
}]
}
'

Description

Writes the specified message to the output

Parameters

Property Type Description
msg string value to write to the output

{
"type": "flexio.echo",
"params": {
"msg": "Hello, World!"
}
}

Returns

Returns the value specified in msg

Email

To add an email task to a pipe that sends an email use the following:

curl -X POST 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"task": [{
"type": "flexio.email",
"params": {
"to": "flexio@mailinator.com",
"subject": "Daily report",
"body_text": "Attached, please find the latest figures",
"body_html": "",
"data": "attachment"
}
}]
}
'

Description

Sends an email

Parameters

Property Type Description
to string the email address to send the message to
subject string the subject of the email
body_text string the body text content of the email
body_html string the body html content of the email
data string enumeration indicating whether not to include the input in the email; if “none” is specified, the input will not be included in the email; if “body” is specified, the input will be appended to the body of the email content; if “attachment” is specified, the input will be included in the email as an attachment

{
"type": "flexio.email",
"params": {
"to": "flexio@mailinator.com",
"subject": "Daily report",
"body_text": "Attached, please find the latest figures",
"body_html": "",
"data": "attachment"
}
}

Returns

Returns the input

Execute

To add an execute task to a pipe that calls a remote python file that writes ‘Hello, World!’, create a pipe with this execute task as follows:

curl -X POST 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"task": [{
"type": "flexio.execute",
"params": {
"lang": "python",
"path": "https://raw.githubusercontent.com/flexiodata/examples/master/functions/hello-world.py",
"integrity": "sha256:891568494dfb8fce562955b1509aee5a1ce0ce05ae210da6556517dd3986de36"
}
}]
}
'

Here, the integrity check is optional, but if it’s included, the content in the “path” must match the integrity check or the job will fail.

Description

Executes code that’s specified inline or in another location, such as a source control repository

Parameters

Property Type Description
lang string the language to execute, using the path if supplied or the code specifed as base64 content in code; lang may be either ‘javascript’ if the code to execute is Javascript or ‘python’ if the code to execute is Python
code string base64-encoded code to execute; takes precendence over any code at path
path string url of the code to execute (e.g. github file URL); if both path and code are specified, the code locally defined in code overrides the code at path
integrity string optional integrity check for the code; if the code given by code or located in the remote path doesn’t match the integrity check, then it fails; integrity checks may use either sha256, sha384, or sha512 values and are specified as ‘sha256:{base64-sha256-value}’, ‘sha384:{base64-sha384-value}’ or ‘sha512:{base64-sha512-value}’

{
"type": "flexio.execute",
"params": {
"lang": "python",
"code": "ZGVmIGZsZXhpb19oYW5kbGVyKGNvbnRleHQpOg0KICAgIGNvbnRleHQub3V0cHV0LmNvbnRlbnRfdHlwZSA9ICJ0ZXh0L3BsYWluIg0KICAgIGNvbnRleHQub3V0cHV0LndyaXRlKCJIZWxsbywgV29ybGQhIik=",
"path": "",
"integrity": ""
}
}

Code to be executed is specified in the code parameter or in the path. This code needs to include a handler function as the main entry point into the code. When an execute task is executed, the code is loaded and checked against supplied integrity value; then the code is run and the handler function is called with a context object.

In Javascript, the handler function is:

exports.flexio_handler = function(context) {}

In Python, the handler function is:

def flexio_handler(context)

The context object is used to exchange information with the pipe process, including reading the output from the previously run step or parameters supplied when the pipe was invoked, as well as writing output to be read by the next task to be run or updating variables to be used in subsequent tasks.

For example, the output from the previous task is passed in through the context objects input parameter and the output from the execute step is passed onto the next task through the output parameter.

Example 1. Javacript handler function that reads input from the previous task and writes it out for the next task:

exports.flexio_handler = function(context) {
context.output.write(context.input.read())
}

Example 2. Python handler function that reads input from the previous task and writes it out for the next task:

def flexio_handler(context):
context.output.write(context.input.read())
}

Returns

The results written to the context object output in the code

Exit

To add an exit task to a pipe that sends a HTTP 404 response, use the following:

curl -X POST 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"task": [{
"type": "flexio.exit",
"params": {
"code": "404"
}
}]
}
'

Description

Stops the execution of the process

Parameters

Property Type Description
code string http header code to return with the result

{
"type": "flexio.exit",
"params": {
"code": "404"
}
}

Returns

Filter

To add a filter task to a pipe that filters a table based on an ‘id’ column, use the following:

curl -X POST 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"task": [{
"type": "flexio.filter",
"params": {
"where": "'id' = 1"
}]
}
'

Description

Filters the rows of the input, passing on rows that satisfy the where condition

Parameters

Property Type Description
where string the filter expression to use to determine whether or not to pass on a row from the input to the output

{
"type": "flexio.filter",
"params": {
"where": "'id' = 1"
}
}

Returns

The filtered input

Render

To add a render task to a pipe that renders the Flex.io homepage to a PNG, use the following:

curl -X POST 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"task": [{
"type": "flexio.render",
"params": {
"url": "https://www.flex.io",
"format": "png",
"width": "800",
"height": "600",
"scrollbars": false
}
}]
}
'

Description

Renders a the contents at a specified url

Parameters

Property Type Description
url string the url to render
format string the format to return the rendered url in; current options are ‘pdf’, ‘png’, and ‘jpeg’
paper string the paper size to use when outputting to a PDF; current options are ‘letter’ and ‘A4’
width string the width in pixels to use when formatting the url that’s being rendered
height string the height in pixels to use when formatting the url that’s being rendered
full boolean whether or not to render the entire url when outputting as an image
landscape boolean whether or not to use landscape mode when outputting to a PDF
scrollbars boolean whether or not to include scrollbars when rendering the url

{
"type": "flexio.render",
"params": {
"url": "https://www.flex.io",
"format": "png",
"width": "800",
"height": "600",
"scrollbars": false
}
}

Returns

The rendered content for the url

Request

To add a request task to a pipe that requests the contents from the Flex.io homepage, use the follwoing

curl -X POST 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"task": [{
"type": "flexio.request",
"params": {
"method": "GET",
"url": "https://www.flex.io"
}
}]
}
'

Description

Issues an HTTP request

Parameters

Property Type Description
method string the http method to use when making the request; options are: “GET” and “POST”
url string the url to issue the request to
connection string optional connection identifier to issue the request to; if a connection identifier is specified, parameters specified in the connection object are used as the default settings for the request with any additional parameters overriding the request parameters and any specified url in the request begin appended to the base url specified in the connection
username string any username to use for basic authentication
password string any password to use for basic authentication
params object data to include as URL parameters in a GET request
data object|string data to include in a POST request
headers object an object with where the keys are the http headers to set and the corresponding values are the values to set those headers to

{
"type": "flexio.request",
"params": {
"method": "GET",
"url": "https://www.flex.io"
}
}

Returns

The body response for the HTTP request

Select

To add a select task to a pipe that returns an ‘id’ and ‘name’ column from a table, use the following:

curl -X POST 'https://www.flex.io/api/v1/pipes/{id}'
--header "Authorization: Bearer {token}"
--header "Content-Type: application/json"
--data '
{
"task": [{
"type": "flexio.select",
"params": {
"columns": [
"id",
"name"
]
}
}]
}
'

Description

Returns the selected columns

Parameters

Property Type Description
columns array an array of the columns names given as strings to include in the result

{
"type": "flexio.select",
"params": {
"columns": [
"id",
"name"
]
}
}

Returns

The input limited to the specified columns