Skip to content

Hello World Tutorial (IQ)

If you haven’t yet please read the IQ Introduction before going through with this tutorial.

The below steps are all done using cURL Commands, the main differences between the commands below are the URL, the Authorization, the Request Body, and the Request Type.

Dictionary

For this tutorial we will define a “Address” collection.

{
    "collection": "address",

    "indexes": [{
        "unique": true,
        "attributes": ["id"]
    }],

    "rootnode": {
        "attributes": [{
            "name": "id",
            "required": true
        }, {
            "name": "addr1"
        }, {
            "name": "addr2"
        }, {
            "name": "city"
        }, {
            "name": "state"
        }, {
            "name": "zip"
        }]
    }
}

Create a string version of the above JSON object and call the PUT for the dictionary endpoint.

    curl \
      -X PUT \
      -u '<username>:<password>' \
      -H 'content-type: application/json' \
      -d '{
        "collection": "address",

        "indexes": [{
            "unique": true,
            "attributes": ["id"]
        }],

        "rootnode": {
            "attributes": [{
                "name": "id",
                "required": true
            }, {
                "name": "addr1"
            }, {
                "name": "addr2"
            }, {
                "name": "city"
            }, {
                "name": "state"
            }, {
                "name": "zip"
            }]
        }
    }'
      https://{ASSIGNED_SERVER}.burstiq.com/api/metadata/dictionary

CRUD

Create/Update

The following JSON object is an address record that we want to store in the collection.

{
    "id": "3456",
    "addr1": "123 Main St",
    "city": "Somewhere",
    "state": "XX",
    "zip": "12345"
}

Then make the following http client call (NOTE it is not currently possible to send multiple records in the same API call – for this use case use the fileloader endpoint). The response is a JSON object indicating success or failure.

    curl \
      -X PUT \
      -u '<username>:<password>' \
      -H 'content-type: application/json' \
      -d '{
        "id": "3456",
        "addr1": "123 Main St",
        "city": "Somewhere",
        "state": "XX",
        "zip": "12345"
    }' \
      https://{ASSIGNED_SERVER}.burstiq.com/api/iq/address

Read (Query)

There are multiple ways to query records in the IQ platform.

Query via TQL where clause

Create a query as a simple where clause

Example:

    {
        "tqlWhereClause": "WHERE state = 'XX'"
    }

Then use the query object to get any documents matching the criteria.

    curl -X POST \
      -u '<username>:<password>' \
      -H 'content-type: application/json' \
      -d '{
        "tqlWhereClause": "WHERE state = '\''XX'\''"
    }' \
      https://{ASSIGNED_SERVER}.burstiq.com/api/iq/<collection_name>/query

Query via TQL query

Similar to the above request, the use of TQL with SELECT can allow more granular selection.

    {
        "queryTql": "SELECT id FROM address WHERE state = 'CO'"
    }
    curl -X POST \
      -H '<username>:<password>' \
      -H 'content-type: application/json' \
      -d '{
        "queryTql": "SELECT * FROM <collection_name> WHERE state = '\''XX'\''"
    }' \
      https://{ASSIGNED_SERVER}.burstiq.com/api/iq/<collection_name>/query

Query via TQLFlow query

Similar to the two requests above, the use of TQLFlow allows you to define just a WHERE clause to query records.

    {
        "queryTqlFlow": "WHERE .state = 'XX'"
    }
    curl -X POST \
      -u '<username>:<password>' \
      -H 'content-type: application/json' \
      -d '{
        "queryTqlFlow": "WHERE state = '\''XX'\''"
    }' \
      https://{ASSIGNED_SERVER}.burstiq.com/api/iq/<collection_name>/query

Query via Map/Reduce

Similar to the above request, the use of Map-Reduce can be used with a different endpoint to the same effect.

    {
        "map": "function() { emit(this.state, this) }",
        "reduce": "function(k, v) { return v[0] }",
        "tqlWhereClause": "WHERE state = 'XX'"
    }

Endpoint:

    curl -X POST \
      -H '<username>:<password>' \
      -H 'content-type: application/json' \
      -d '{
        "map": "function() { emit(this.state, this) }",
        "reduce": "function(k, v) { return v[0] }",
        "tqlWhereClause": "WHERE state = '\''XX'\''"
    }' \
      https://{ASSIGNED_SERVER}.burstiq.com/api/iq/{collection_name}/mapreduce/query

Delete

Deleting records is done via a basic where clause.

    {
        "tqlWhereClause": "WHERE state = 'XX'"
    }

Then make the following http client call. The response will contain the number of records that were deleted.

curl -X DELETE \
  -u '<username>:<password>' \
  -H 'content-type: application/json' \
  -d '{
    "tqlWhereClause": "WHERE state = '\''XX'\''"
}' \
  https://{ASSIGNED_SERVER}.burstiq.com/api/iq/<collection_name>/query