REST API

HTTP service and data management

API Reference


The Eventn API exclusively supports JSON for requests and responses.

Resource Summary

service.eventn.com

Invoke a microservice by making an HTTP request.

ResourceGETPOST
/{service_id}Execute GET functionExecute POST function

api.eventn.com

ResourceGETPOSTPUTDELETE
/authentication-Returns a valid authentication token and user object. Read More--
/log/{request_id}Returns all log entries for a given request ID. Read More---
/log/{service_id}Returns all log entries for a given service ID. Read More---
/serviceReturns all service function definitions. Read MoreCreate new service. Read More--
/service/{service_id}Returns a service function definition.-Update a service function.-
/storeReturn all stores. Read MoreCreate a new store. Read More--
/store/{store_id}Returns a store. Read More-Update a storeDelete a store

Authentication Overview

All authenticated requests to the Eventn API must have anauthorizationheader set:

authorization:Bearer auth_token...

The token creation process and lifespan differs depending upon which API URI is being accessed (see Separation Of Concerns for more information).

URIExpirationToken Generation Process
api.eventn.com24 hoursSeePOST /authentication
service.eventn.comNeverReturned as part of service creation response. SeePOST /service. Also available within the user interface.

service.eventn.com

GET /{service_id}

Invoke the serviceGETfunction. The GET function executes synchronously.

Example Request

curl -H "Content-Type: application/json" \
-H "Authorization: Bearer {SERVICE_TOKEN}" \
https://service.eventn.com/{SERVICE_NAME}

POST /{service_id}

Invoke the servicePOSTfunction. The POST function executes asynchronously.

Example Request

curl -H "Content-Type: application/json" \
-H "Authorization: Bearer {SERVICE_TOKEN}" \
-X POST -d '{"Hello":"World"}' \
https://service.eventn.com/[SERVICE_ID]

api.eventn.com

POST /authentication

Generate an authentication token for use with any otherapi.eventn.comresource. Returns a valid authentication token and user object payload.

Parameters

email

Required. The email associated with the Eventn account.

password

Required. The password associated with the Eventn account.

Example Request

curl -H "Content-Type: application/json" \
-X POST -d '{"email":"[ACCOUNT_EMAIL]","password":"[ACCOUNT_PASSWORD]"}' \
https://api.eventn.com/authentication

Example request payload:

{
  "email": "EVENTN_ACCOUNT_EMAIL",
  "password": "EVENTN_ACCOUNT_PASSWORD"
}

Example Response

{
    "status": "success",
    "data": {
        "token": "eyJ0eXAiOiJ.....",
        "user": {
            "id": 4386,
            "first_name": "Yogi",
            "last_name": "Bear",
            "email": "hello@eventn.com"
        }
    }
}

GET /log/REQUEST_ID

Returns all log entries for a specified request. Astatusproperty is returned as part of the response detailing the request status ofqueued,successorerroralong with associated debug data for each status..

Parameters

request_id

Required. The ID of a specific service request. Note, a request ID is returned by making either aGETorPOSTrequest toservice.eventn.com/SERVICE_ID.

Example Request

curl -H "Content-Type: application/json" \
-H "Authorization: Bearer [VALID_TOKEN]" \
https://api.eventn.com/log/[REQUEST_ID]

Example Response

{
  "status": "success",
  "data": [
    {
      "id": 80305,
      "ts_created": "2016-12-25T21:07:51.000Z",
      "user_id": 1,
      "service_id": "SV_P3ZFWQNL",
      "request_id": "f945270c-b407-4477-8307-9c865891a140",
      "method": "post",
      "type": "queued",
      "data": "{\"fn\": \"function onPost(context, request) {\\n      return context.store().insert({ data: JSON.stringify(request.payload) });\\n}\\nmodule.exports = onPost;\", \"pid\": 7920, \"query\": {}, \"payload\": \"{\\\"test\\\":\\\"data\\\"}\"}"
    },
    {
      "id": 80306,
      "ts_created": "2016-12-25T21:07:51.000Z",
      "user_id": 1,
      "service_id": "SV_P3ZFWQNL",
      "request_id": "f945270c-b407-4477-8307-9c865891a140",
      "method": "post",
      "type": "success",
      "data": "{\"fn\": \"function onPost(context, request) {\\n      return context.store().insert({ data: JSON.stringify(request.payload) });\\n}\\nmodule.exports = onPost;\", \"pid\": 7920, \"query\": {}, \"result\": {\"mem\": {\"rss\": \"52.16\"}, \"result\": [40003], \"timers\": {\"vmDiff\": [0, 42435230], \"totalDiff\": [0, 694882431], \"loadingEnd\": [3459359, 212868806], \"loadingDiff\": [0, 650711662], \"executionEnd\": [3459359, 257041916], \"loadingStart\": [3459358, 562168408], \"executionDiff\": [0, 44177853]}}, \"payload\": \"{\\\"test\\\":\\\"data\\\"}\"}"
    }
  ]
}

GET /log/SERVICE_ID

Returns the most recent 50 log entries for a specified service.

Parameters

service_id

Required. The ID of a specific service.

Example Request

curl -H "Content-Type: application/json" \
-H "Authorization: Bearer [VALID_TOKEN]" \
https://api.eventn.com/log/[SERVICE_ID]

Example Response

{
  "status": "success",
  "data": [
    {
      "id": 13,
      "ts_created": "2017-02-21T05:25:24.000Z",
      "user_id": 1,
      "service_id": "SV_P3RANS9MC",
      "request_id": "70b7a992-a1a5-4a08-918e-1361d204f5dc",
      "method": "post",
      "type": "queued",
      "data": "{\"fn\": \"function onPost(context, request) {\\n    return context.store().insert({ data: JSON.stringify(request.payload) });\\n}\\n\\nmodule.exports = onPost;\\n\", \"pid\": 28211, \"query\": {}, \"payload\": \"{\\\"test\\\":\\\"data\\\"}\"}"
    },
    {
      "id": 14,
      "ts_created": "2017-02-21T05:25:25.000Z",
      "user_id": 1,
      "service_id": "SV_P3RANS9MC",
      "request_id": "70b7a992-a1a5-4a08-918e-1361d204f5dc",
      "method": "post",
      "type": "success",
      "data": "{\"fn\": \"function onPost(context, request) {\\n    return context.store().insert({ data: JSON.stringify(request.payload) });\\n}\\n\\nmodule.exports = onPost;\\n\", \"pid\": 28211, \"query\": {}, \"result\": {\"mem\": {\"rss\": \"52.86\"}, \"result\": [1], \"timers\": {\"vmDiff\": [0, 41840121], \"totalDiff\": [0, 739434914], \"loadingEnd\": [8414079, 876748203], \"loadingDiff\": [0, 694536058], \"executionEnd\": [8414079, 921647803], \"loadingStart\": [8414079, 182220408], \"executionDiff\": [0, 44904180]}}, \"payload\": \"{\\\"test\\\":\\\"data\\\"}\"}"
    }
  ]
}

GET /service

List all services definitions.

Example Request

curl -H "Content-Type: application/json" \
-H "Authorization: Bearer [VALID_TOKEN]" \
https://api.eventn.com/service

Example Response

{
  "status": "success",
  "data": [
    {
      "id": "SV_PK7C2MTLC",
      "description": "Example 1",
      "get_fn": "function onGet(context) {\n    return context.stores.default().table().select();\n}\n\nmodule.exports = onGet;\n",
      "post_fn": "function onPost(context, request) {\n    return context.stores.default().table().insert({ data: JSON.stringify(request.payload) });\n}\n\nmodule.exports = onPost;\n",
      "token": "6ec83457-415f-4178-93d9-66bc3eb558bf",
      "created_at": "2017-03-26T22:24:37.000Z",
      "updated_at": "2017-03-30T17:54:45.000Z",
      "name": "SV_PK7C2MTLC"
    },
    {
      "id": "SV_PKWXLDYEC",
      "description": "Example 2",
      "get_fn": "function onGet(context) {\n    return context.stores.default().table().select();\n}\n\nmodule.exports = onGet;\n",
      "post_fn": "function onPost(context, request) {\n    return context.stores.default().table().insert({ data: JSON.stringify(request.payload) });\n}\n\nmodule.exports = onPost;\n",
      "token": "9ec83457-415f-4158-93e9-61bb3eb558bf",
      "created_at": "2017-04-02T20:23:22.000Z",
      "updated_at": "2017-04-02T20:24:46.000Z",
      "name": "SV_PKWXLDYEC"
    }
  ]
}

POST /service

Create a new service.

Parameters

description

Optional. A textual description of the service. Shown within the user interface and returned viaGET /service.

Example Request

curl -H "Content-Type: application/json" \
-H "Authorization: Bearer [VALID_TOKEN]" \
-X POST -d '{ "description": "[DESCRIPTION]" }' \
https://api.eventn.com/service

Example Response

{
  "status": "success",
  "data": {
    "id": "SV_F33BS7HNC",
    "description": "Example Description",
    "get_fn": "function onGet(context) {\n    return context.stores.default().table().count();\n}\n\nmodule.exports = onGet;\n",
    "post_fn": "function onPost(context, request) {\n    return context.stores.default().table().insert({ data: JSON.stringify(request.payload) });\n}\n\nmodule.exports = onPost;\n",
    "token": "7ec83457-415f-4178-93e9-66bb3eb558bf",
    "created_at": "2017-04-21T17:41:08.000Z",
    "updated_at": "2017-04-21T17:41:08.000Z"
  }
}

GET /store

List all store definitions.

Example Request

curl -H "Content-Type: application/json" \
-H "Authorization: Bearer [VALID_TOKEN]" \
https://api.eventn.com/store

Example Response

{
  "status": "success",
  "data": [
    {
      "id": "1817e1ee-2425-4feb-bf23-52e07s1b698a",
      "name": "warehouse",
      "adapter_type": "mysql",
      "connection_string": "mysql://root:password@0.tcp.ngrok.io:14121/demo",
      "default_table": "booboo",
      "created_at": "2017-03-28T03:12:13.000Z",
      "updated_at": "2017-03-28T03:12:13.000Z"
    },
    {
      "id": "SV_F33BS7HNC",
      "name": "SV_F33BS7HNC",
      "adapter_type": "mysql",
      "default_table": "SV_F33BS7HNC",
      "created_at": "2017-04-21T17:41:08.000Z",
      "updated_at": "2017-04-21T17:41:08.000Z"
    }
  ]
}

POST /store

Create a new store. A store is a function that can be called inside of a microservice used for connecting to a database.

Parameters

adapter_type

Required. Eitherpgfor PostgreSQL,mysqlfor MySQL or MariaDB, ormssqlfor MSSQL.

name

Required. A name to reference the function. Used for invocation within a microservice.

default_table

Optional. Specify a default table name to be used when the store function is called.

connection_string

The connection string to be used to connect to a database. Example format:
[TYPE]://[DB_USER]:[DB_PASSWORD]@[HOST]:[PORT]/[DATABASE]

Example Request

curl -H "Content-Type: application/json" \
-H "Authorization: Bearer [VALID_TOKEN]" \
-X POST -d '{ "adapter_type": "[TYPE]", "name": "[NAME]", "default_table": "[DEFAULT_TABLE]", "connection_string": "[TYPE]://[USER]:[PASSWORD]@[HOST]:[PORT]/[DATABASE]"}' \
https://api.eventn.com/store

Example Response

{
  "status": "success",
  "data": {
    "id": "391444e0-36b3-45ed-808b-bb14befc4bcd",
    "name": "warehouse",
    "adapter_type": "mysql",
    "connection_string": "mysql://dbuser:password@0.tcp.ngrok.io:12221/demo",
    "default_table": "foo",
    "internal": 0,
    "created_at": "2017-03-26T19:35:28.000Z",
    "updated_at": "2017-03-26T19:35:28.000Z"
  }
}

GET /store

Retrieve a specific store definition.

Example Request

curl -H "Content-Type: application/json" \
-H "Authorization: Bearer [VALID_TOKEN]" \
https://api.eventn.com/store/[STORE_ID]

Example Response

{
  "status": "success",
  "data": {
    "id": "2117e1ee-2424-4feb-cf23-51e07c1b698a",
    "name": "warehouse",
    "adapter_type": "mysql",
    "connection_string": "mysql://root:password@0.tcp.ngrok.io:16121/demo",
    "default_table": "booboo",
    "created_at": "2017-03-28T03:12:13.000Z",
    "updated_at": "2017-03-28T03:12:13.000Z"
  }
}