DATA API

Connect your data to your app instantly and securely

Our mission is to empower organizations by democratizing access to data. We believe that seamless and secure data access is the key to unlocking its full potential. Our Data API offers a user-friendly and secure gateway to your organization's data assets, ensuring that you can access and manage your data anytime, anywhere, without compromising on security.

What you can do with Data API

  • Read (with query or not)

  • Write (with batch or not)

  • Update

  • Delete

How to access Data API

  1. Go to your collection

  2. Click Integration and select API

  3. The description shows how you can access the API using different programming language.

How to use API call

Read Data with query

By default, the read API return all the data in the collection which can be inefficient and so we recommend you use read with query. Essentially, it allows you to 1) filter, 2) project (select the fields you want), 3) sort, and 4) limit (limit the amount of data returned). For example, imagine your collection looks like this in JSON format.

[
    {
        "amount": 10,
        "title": "Movie ABC"
    }, 
    {
        "amount": 100,
        "title": "Movie BDD"
    }, 
    {
        "amount": 39,
        "title": "Movie XYZ"
    }
]

You can access your data using the requests library with Python. The syntax for filter is based on MongoDB query language.

# Import Library
import requests

# Request data using POST
data = requests.post(
    url='https://app.connectomesystem.com/collection/readwithquery/<read credential>/<collection id>',
    json={
        "query": {"amount":{"$gte":30}},
        "project": {"amount": 1, "title": 1},
        "sort": {"amount": 1},
        "limit": 10
        }
    )
    

Update data with upsert

Allows to update the data in the specific field(s) and insert new data if the data in search do not exist.

Usage:

# Import library
import requests

# Only the POST method allows in the update method.
resp = requests.post(
    url='https://app.connectomesystem.com/collection/updatewithupsert/<write credential/<collection id>',
    json={
        "search query": {
            "<field name 1>": "foo",
            "<field name 2>": "bar"
        },
        "data": {
            "<field name 3>": "baz"
        },
        "upsert": True
    }
)
KeyDescription

search query

Used to identify which data need to be updated. Field names are the fields that are defined in your collection.

data

The modification to apply

upsert

Boolean. Creates a new document if no documents match the filter. For more details see upsert behavior. Default to False.

Noted that this function can return an error code due to no result found by the search query.

Upload with batch data

Inserts multiple documents into a collection

Usage:

# Import library
import requests

# Only the POST method allows in the upload method.
resp = requests.post(
    url='https://app.connectomesystem.com/collection/batchwrite/<write credential>/<collection id>',
    json={
        [
            {
                "field 1": "foo"
            },
            {
                "field 1": "bar"
            }
        ]
    }
)

This API parameter needs an array of data. The batch data will be inserted into the collection all at one time.

Delete batch data with a query

Remove all the data that match the condition defined in the query.

Usage:

# Import library
import requests

# Only the DELETE method allows in the remove method.
resp = requests.delete(
    url='https://app.connectomesystem.com/collection/batchdelete/<write credential>/<collection id>',
    json={
        'field 1': 'foo',
        'field 2': 'bar'
    }
)

The API parameter takes a query in JSON format. Any data will be removed if match the query.

Last updated