Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

This tutorial will walk you through using the Squirro API. It shows first how to authenticate and then how to access any of the entities from the API.

1. Authentication

The tenant and user_id which belong to the provided authorization information are obtained during Bearer Token Creation. It is advised to take good note of these values as they are used for most API requests.

2. User Data Retrieval

All user data can be retrieved with a single request towards the Squirro API. Notice that currently user data can only be retrieved by providing an access token.

client.get_user_data('<user_id>')

A sample JSON response is shown below.

{
    "config": {
        "languages": [
        "en",
        "fr",
        "de"
        ],
        "market": "en-US",
        "noise_level": 1.0,
        "timezone": "Europe/Zurich"
    },
    "email": "sid@squirro.com",
    "full_name": "Sid Squirro",
    "id": "ug5GF9TWR26buu493Ay43w",
    "known_languages": "[\"en\"]",
    "tenant": "squirro",
    "utc_offset": "3600000"
}

3. Folder & Topic Creation

After having completed that previous step a new user folder is created. Within the folder a new topic is created. It is also illustrated how folders and topics can be retrieved.

The tenant and user_id which belong to the provided authorization information are obtained during Bearer Token Creation. It is advised to take good note of these values as they are used for most API requests.

3.1. Folder Creation

After a valid access token has been received a new user folder “My Contacts” is created. The seeder for the folder is set to “my-rest-seeder”.

client.new_folder('My Contacts', seeder='my-rest-seeder')

A sample JSON response is shown below.

{
    "id": "-nYqTGwzRNyLK_K6RhxCeg"
}

3.2. Folder Retrieval

In a second step all available folders for the user are retrieved.

client.get_user_folders()

A sample JSON response is shown below.

[
    {
        "title": "My Contacts",
        "topics": 1,
        "seeder": "my-rest-seeder",
        "is_public": false,
        "type": "my contacts",
        "id": "Sz7LLLbyTzy_SddblwIxaA"
    },
    {
        "title": "My Organizations",
        "topics": 2,
        "seeder": "team",
        "is_public": false,
        "type": "my organizations",
        "id": "2aEVClLRRA-vCCIvnuEAvQ"
    }
]

3.3. Topic Creation

After the folder “My Contacts” has been registered a new topic “Squirro” within the folder “My Contacts” is created.

client.new_topic(<folder_id>, 'Squirro', seeder='my-rest-seeder')

A sample JSON response is shown below.

{
    "id": "yr9acZuKRc6YPswWm63m-Q",
    "folder_id": "-nYqTGwzRNyLK_K6RhxCeg"
}

3.4. Topic Retrieval

In a second step all available topics in a folder are retrieved.

client.get_user_topics(folder_id=<folder_id>)

A sample JSON response is shown below.

[
    {
        "is_ready": true,
        "folder_id": "Sz7LLLbyTzy_SddblwIxaA",
        "noise_level": null,
        "title": "Alexander Sennhauser",
        "seeder": "team",
        "needs_preview": false,
        "type": "contact",
        "id": "zFe3V-3hQlSjPtkIKpjkXg",
        "weight": 0.0,
        "subscribed_to": true
    },
    {
        "is_ready": true,
        "folder_id": "Sz7LLLbyTzy_SddblwIxaA",
        "noise_level": null,
        "title": "Memonic",
        "seeder": "my-reset-seeder",
        "needs_preview": false,
        "type": "my contacts",
        "id": "2sic33jZTi-ifflvQAVcfw",
        "weight": 0.0,
        "subscribed_to": true
    }
]
  • No labels