Queries

Queries are the defined platform queries that can be used to fetch, update, create, or delete data. Queries are paired with Sources and encapsulated as a single object within nokori. This allows platform functionality to be utilized across all queries and 100% of supported data sources in exactly the same way. 🤯

Practically, this means queries become subscribable, eventable, and dare we say, ✨magical✨, regardless of backend database. This strips away vendor-specific implementation details of each database and creates a universal developer experience without requiring deep, specific knowledge of each database.

Universal Access

Queries make databases accessible from anywhere -- without building an API -- including browsers 🥳 🎉.

This is a huge value-add for front-end engineers who don't want to go through the laborious task of building an API just to power a frontend app. Through our APIs and SDKs, frontend engineers can get data in frontend applications from any supported Source in a matter of moments.


POST/v1/queries

Create a Query

This endpoint allows you to create a query. For quickstart purposes, we recommend using the nokori UI.

Request Body Parameters

  • Name
    hubId
    Type
    string
    required
    Description

    The id of the hub this query is associated with.

  • Name
    label
    Type
    string
    required
    Description

    A user friendly name for the query.

  • Name
    sourceId
    Type
    string
    required
    Description

    The source this query will execute against.

  • Name
    query
    Type
    string
    required
    Description

    The query to execute. For SQL based sources, this is a SQL query, for example.

  • Name
    command
    Type
    string
    optional
    Description

    The command to execute. For SQL based sources, this defaults to SELECT. This is not required for all sources.

  • Name
    parentNodeId
    Type
    string
    optional
    Description

    The tree node id in the hub that this query parents from. Can be a folder node id or the root Queries node id. Defaults to root Queries node id.

Request

POST
/v1/queries
curl https://api.nokori.com/v1/queries \
  -X POST \
  -H 'x-nokori-api-key: {{apiKey}}' \
  -H 'Content-Type: application/json' \
  -d '{
        "hubId": "lola.hub.hsnwg921TBQbNKeNMjS", 
        "label": "Get all orders", 
        "sourceId" : "lola.src.9H-svSEqWVHKvyuZWLM",
        "command": "SELECT"
        "query" : "SELECT * FROM orders"
      }'

Response

200 OK
{
  "meta": {
    "engine": "mysql",
    "hubId": "lola.hub.6491IQxDmgecF86YFsZ",
    "label": "Get all orders"
  },
  "config": {
    "command": "SELECT",
    "context": null,
    "query": {
      "queryId": "lola.q.Yum6RAQFvj2eMf5kLKR",
      "query": "SELECT * FROM orders"
    },
    "source": { 
      "sourceId": "lola.src.9H-svSEqWVHKvyuZWLM", 
      "engine": "mysql" 
    }
  }
}

GET/v1/queries/:queryId

Get a Query

This endpoint allows you to get a query.

Query Parameters

  • Name
    queryId
    Type
    string
    required
    Description

    The id of your Query

Request

GET
/v1/queries/:queryId
curl -G https://api.nokori.com/v1/queries/:queryId \
  -H 'x-nokori-api-key: {{apiKey}}'

Response

200 OK
{
  "meta": {
    "engine": "mysql",
    "label": "Get all orders",
    "hubId": "lola.hub.hsnwg921TBQbNKeNMjS",
  },
  "config": {
    "command": "SELECT",
    "context": [],
    "query": {
      "queryId": "lola.q.Yum6RAQFvj2eMf5kLKR",
      "query": "SELECT * FROM orders",
    },
    "source": {
      "sourceId": "lola.src.9H-svSEqWVHKvyuZWLM",
      "engine": "mysql",
    },
  },
}

POST/v1/queries/execute

Execute a Query

This endpoint allows you to execute a platform query. Platform Queries are subscribable, and executable directly from anywhere, even browsers.

Request Body Parameters

  • Name
    queryId
    Type
    string
    required
    Description

    The query id of the query to execute

  • Name
    context
    Type
    object
    optional
    Description

    The object containing the context for the query. Queries support

Request

POST
/v1/queries/execute
curl https://api.nokori.com/v1/queries/execute \
  -X POST
  -H 'x-nokori-api-key: {{apiKey}}' \
  -H 'Content-Type: application/json' \
  -d '{"queryId": "lola.q.Yum6RAQFvj2eMf5kLKR", "context": {}}'

Response

200 OK
{
    "data" : [...] // Array of results
}

PUT/v1/queries/:queryId

Update a Query

This endpoint allows you to update your queries.

The update route supports partial update objects. For example, we update just the executable query in this example.

Query Parameters

  • Name
    queryId
    Type
    string
    required
    Description

    The query id of the query to update

Request Body Parameters

  • Name
    meta.label
    Type
    string
    optional
    Description

    The name of your query

  • Name
    config.command
    Type
    string
    optional
    Description

    The command of your query. For SQL based queries, this is the SQL command (SELECT, INSERT, UPDATE, DELETE, etc.)

  • Name
    config.context
    Type
    array
    optional
    Description

    Key/Value array of context variables for your query

  • Name
    config.query.query
    Type
    string
    optional
    Description

    Query string to execute

  • Name
    config.source.sourceId
    Type
    string
    optional
    Description

    Source Id for the Source the query will execute against

Request

PUT
/v1/queries/:queryId
curl https://api.nokori.com/v1/queries/:queryId \
  -X PUT
  -H 'x-nokori-api-key: {{apiKey}}' \
  -H 'Content-Type: application/json'
  -d '{
  "config": {
    "query": {
      "query": "SELECT * FROM orders ORDER by created DESC LIMIT 10"
    }
  }
}'

Response

200 OK
{}

DELETE/v1/queries/:queryId

Delete a Query

This endpoint allows you to create a hub.

Query Parameters

  • Name
    queryId
    Type
    string
    required
    Description

    The queryId to delete

Request

DELETE
/v1/queries/:queryId
curl https://api.nokori.com/v1/queries/:queryId \
  -X DELETE \
  -H 'x-nokori-api-key: {{apiKey}}' \
  -H 'Content-Type: application/json'

Response

200 OK
{}