fingoti-sdk

Fingoti SDK


Keywords
Fingoti, SDK, API, IoT, Pebl
Install
pip install fingoti-sdk==1.0.0

Documentation

fingoti-sdk

Requirements.

Python >=3.6

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install fingoti-sdk

(you may need to run pip with root permission: sudo pip install fingoti-sdk)

Then import the package:

import fingoti

Getting Started

Please follow the installation procedure and then run the following:

import time
import fingoti
from pprint import pprint
from fingoti.api import device_api
from fingoti.model.claim_request import ClaimRequest
from fingoti.model.claim_result import ClaimResult
from fingoti.model.claimed_device_response import ClaimedDeviceResponse
from fingoti.model.claimed_devices_dto import ClaimedDevicesDto
from fingoti.model.default import Default
from fingoti.model.device_nodes_response import DeviceNodesResponse
from fingoti.model.device_request import DeviceRequest
from fingoti.model.mqtt_device_response import MqttDeviceResponse
from fingoti.model.patch_gateway import PatchGateway
from fingoti.model.update_request import UpdateRequest
from fingoti.model.update_response import UpdateResponse
# Defining the host is optional and defaults to https://api.fingoti.com
# See configuration.py for a list of all supported configuration parameters.
configuration = fingoti.Configuration(
    host = "https://api.fingoti.com"
)

# Configure API key authorization: Bearer
configuration.api_key['Bearer'] = '<YOUR_API_KEY>'
configuration.api_key_prefix['Bearer'] = 'Bearer'


# Enter a context with an instance of the API client
with fingoti.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = device_api.DeviceApi(api_client)
    id = "id_example" # str |

    try:
        # Unclaim a Fingoti device.
        api_response = api_instance.delete_device_id(id)
        pprint(api_response)
    except fingoti.ApiException as e:
        print("Exception when calling DeviceApi->delete_device_id: %s\n" % e)

Getting Started - Not generated

Here we will briefly cover the steps needed to get up and running with the SDK

Create a configuration

The first step to communicating with the Fingoti infrastructure is authentication and configureation, to do this you will need an API key which can be obtained from http://account.fingoti.com, once you have an API key you can create a configuration as shown below

import fingoti

config = fingoti.Configuration()
config.api_key["Bearer"] = "<your-api-key>"
config.api_key_prefix["Bearer"] = "Bearer"

Now you have a configuration we can use that to authenticate requests to the Fingoti infrastructure, lets start with a basic Organisation information request.

Using the APIs

In the SDK the diffrent sections of the infrastructure are split into seperate API's in the example below, we are going to use the Organisation API to retrieve basic information about your Organisation.

from fingoti.api import organisation_api

with fingoti.ApiClient(config) as api_client:

    organisationApi = organisation_api.OrganisationApi(apiClient)

    try:
        response = organisationApi.get_organisation()
        pprint(response)
    except fingoti.ApiException as e:
        print("Exception when calling get_organisation: %s\n" % e)

You should see a response containing your organisation information printed in the terminal, if it does, great! You can now explore the rest of the docuemntation to find API's that fit your requirements.

Device Control/Communication

Alongside the API's this package also comes with what we call a command builder which allows you to assemble requests to send to your Fingoti devices. It works in a similar way to the other API's and takes the same configuration shown in Create a configuration, see below

from fingoti.command import builder

with fingoti.ApiClient(config) as api_client:
    commands = builder.Builder(api_client, "A0B1C3D4E5")

    """
    Device commands can have read or write operation, in general read commands do not require a payload

    All write operations require a payload
    """

    "Adds a deviceColour read command, deviceColour has a read & write operation, in this case we do not need to send a payload for the read command"
    commands.addDeviceColour()

    "Adds a deviceColour write command, as this is a deviceColour write command we are adding a payload"
    commands.addDeviceColour(100, 25, 75)

    "Adds a devicePower read command, devicePower only has a read command, therefore no payload is required"
    commands.addDevicePower()

    "Adds a uartData write command, uartData only has a write command so it requires a payload"
    commands.addUARTData([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100])

    """
    As mentioned in some cases a read command will require a payload

    We will demonstrate this with a scheduleCron command
    """

    "Adds a scheduleCron read command, this will read the cron string for schedule slot 2"
    commands.addScheduleCron(2)

    "Adds a scheduleCron write command, this will set the cron string for schedule slot 2"
    commands.addScheduleCron(2, "20 * * * *")

    "The .log() method will print what the builder has assembled in the background, this is useful for debugging"
    commands.log()

    "Once you've finished assembling commands, send them"
    result = commands.send()
    print(result.to_dict())

After running the script you should see 2 outputs, the first one is the what was sent to the device and the second is what the device responded with, This is just a small introduction into the command builder and you can find a full list of avaliable commands, HERE

Documentation for API Endpoints

Class Method HTTP request Description
DeviceApi delete_device_id DELETE /v1/device/{id} Unclaim a Fingoti device.
DeviceApi get_device GET /v1/device Get all devices.
DeviceApi get_device_id GET /v1/device/{id} Get specified device.
DeviceApi get_device_id_nodes GET /v1/device/{id}/nodes Get all nodes latched to a gateway.
DeviceApi patch_device_id PATCH /v1/device/{id} Update your Fingoti device.
DeviceApi post_device POST /v1/device Claim a new Fingoti device.
DeviceApi post_device_sendrequest POST /v1/device/sendrequest Send a request to a Fingoti device.
DeviceApi post_device_update POST /v1/device/update Initiate a device update.
FollowingsApi delete_followings_id DELETE /v1/followings/{id} Delete a Pin Following. This is not recoverable.
FollowingsApi get_followings GET /v1/followings Get all pin followings.
FollowingsApi get_followings_id GET /v1/followings/{id} Get specified pin following.
FollowingsApi patch_followings_id PATCH /v1/followings/{id} Update pin following.
FollowingsApi post_followings POST /v1/followings Create a new pin following.
OrganisationApi delete_organisation_addresses_id DELETE /v1/organisation/addresses/{id} Delete an address. This is not recoverable.
OrganisationApi delete_organisation_presets_id DELETE /v1/organisation/presets/{id} Delete specified preset.
OrganisationApi delete_organisation_roles_id DELETE /v1/organisation/roles/{id} Delete a role. Role must not be assigned to any users. This is not recoverable.
OrganisationApi delete_organisation_tokens_id DELETE /v1/organisation/tokens/{id} Delete a Token. Token will no longer authenticate API requests. This is not recoverable.
OrganisationApi delete_organisation_users_id DELETE /v1/organisation/users/{id} Remove a user from the organisation.
OrganisationApi get_organisation GET /v1/organisation Get your Fingoti organisaiton information.
OrganisationApi get_organisation_addresses GET /v1/organisation/addresses Get all addresses.
OrganisationApi get_organisation_addresses_id GET /v1/organisation/addresses/{id} Get specified address.
OrganisationApi get_organisation_partner GET /v1/organisation/partner Get partner information.
OrganisationApi get_organisation_presets GET /v1/organisation/presets Get all presets.
OrganisationApi get_organisation_presets_id GET /v1/organisation/presets/{id} Get specified preset.
OrganisationApi get_organisation_roles GET /v1/organisation/roles Get all roles.
OrganisationApi get_organisation_roles_id GET /v1/organisation/roles/{id} Get specified role.
OrganisationApi get_organisation_tenants GET /v1/organisation/tenants Get all tenants.
OrganisationApi get_organisation_tokens GET /v1/organisation/tokens Get all API tokens.
OrganisationApi get_organisation_tokens_id GET /v1/organisation/tokens/{id} Get specified token.
OrganisationApi get_organisation_users GET /v1/organisation/users Get all users.
OrganisationApi get_organisation_users_id GET /v1/organisation/users/{id} Get specidfied user.
OrganisationApi patch_organisation PATCH /v1/organisation Update your Fingoti organisation.
OrganisationApi patch_organisation_addresses_id PATCH /v1/organisation/addresses/{id} Update organisation address.
OrganisationApi patch_organisation_presets_id PATCH /v1/organisation/presets/{id} Update organisation preset.
OrganisationApi patch_organisation_roles_id PATCH /v1/organisation/roles/{id} Update organisation role.
OrganisationApi patch_organisation_tokens_id PATCH /v1/organisation/tokens/{id} Update API token.
OrganisationApi patch_organisation_users_id PATCH /v1/organisation/users/{id} Update organisation user.
OrganisationApi post_organisation POST /v1/organisation Register a new Fingoti organisation.
OrganisationApi post_organisation_addresses POST /v1/organisation/addresses Create a new address.
OrganisationApi post_organisation_presets POST /v1/organisation/presets Create a new preset.
OrganisationApi post_organisation_roles POST /v1/organisation/roles Create a new role.
OrganisationApi post_organisation_tenants POST /v1/organisation/tenants Create new tenant. This is only available to partner organisations.
OrganisationApi post_organisation_tokens POST /v1/organisation/tokens Generate new API token.
OrganisationApi post_organisation_users POST /v1/organisation/users Invite a new user to the organisation.
ReportApi get_report_id_commands GET /v1/report/{id}/commands Retrieve command log
ReportApi get_report_usage GET /v1/report/usage Retrieve property usage statistics per day per device
UserApi delete_user_tokens_id DELETE /v1/user/tokens/{id} Delete a Token. Token will no longer authenticate API requests. This is not recoverable.
UserApi get_user GET /v1/user Get your Fingoti user.
UserApi get_user_organisations GET /v1/user/organisations Get all organisations you are a member of.
UserApi get_user_sessions GET /v1/user/sessions Get all user sessions.
UserApi get_user_tokens GET /v1/user/tokens Get all API tokens.
UserApi get_user_tokens_id GET /v1/user/tokens/{id} Get specified token.
UserApi patch_user PATCH /v1/user Update Fingoti user.
UserApi patch_user_tokens_id PATCH /v1/user/tokens/{id} Update API token.
UserApi post_user POST /v1/user Register a new Fingoti user.
UserApi post_user_tokens POST /v1/user/tokens Generate new API token.
WebhookApi delete_webhook_id DELETE /v1/webhook/{id} Delete a Webhook. This is not recoverable.
WebhookApi get_webhook GET /v1/webhook Get all registered webhooks.
WebhookApi get_webhook_id GET /v1/webhook/{id} Get specified webhook.
WebhookApi get_webhook_logs GET /v1/webhook/logs Get all registered webhooks with call logs.
WebhookApi patch_webhook_id PATCH /v1/webhook/{id} Update Fingoti webhook.
WebhookApi post_webhook POST /v1/webhook Register a new webhook.
WebhookApi post_webhook_retry POST /v1/webhook/retry Retry a webhook.

Documentation For Models

Documentation For Authorization

Bearer

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

Author

Notes for Large OpenAPI documents

If the OpenAPI document is large, imports in fingoti.apis and fingoti.models may fail with a RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:

Solution 1: Use specific imports for apis and models like:

  • from fingoti.api.default_api import DefaultApi
  • from fingoti.model.pet import Pet

Solution 2: Before importing the package, adjust the maximum recursion limit as shown below:

import sys
sys.setrecursionlimit(1500)
import fingoti
from fingoti.apis import *
from fingoti.models import *