Skip to main content

emo platform api python sdk

Project description

BOCCO emo platform api python sdk (β version)

How to install

Using poetry (if you want to use in python virtual environment)

If poetry has not been installed, please see this page to install.

# Python 3.7+ required
poetry install --no-dev

When you execute python code,

poetry run python your_python_code.py

Using PyPl

# Python 3.7+ required
$ pip3 install emo-platform-api-sdk

Setting api tokens

You can see access token & refresh token from dashboard in this page after login.

Then, set those tokens as environment variables.

export EMO_PLATFORM_API_ACCESS_TOKEN="***"
export EMO_PLATFORM_API_REFRESH_TOKEN="***"

Usage Example

You can also see other examples in "examples" directory.

Note

  • When you initialize emo_platform.Client, two json files (emo-platform-api.json & emo-platform-api_previous.json) are created in the path where emo_platform module was installed.
    • These files are used to store the tokens information.
    • See the documentation for details.
  • You can change the path where these json files are created, as shown below.
import os
from emo_platform import Client

CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))

client = Client(token_file_path=CURRENT_DIR)

Example1 : Using client

from emo_platform import Client, Head

client = Client()

print(client.get_account_info())
print(client.get_stamps_list())

room_id_list = client.get_rooms_id()
room_client = client.create_room_client(room_id_list[0])

print(room_client.get_msgs())
room_client.move_to(Head(10,10))

Example2 : Receive webhook

In another terminal, execute ngrok and copy URL forwarded to http://localhost:8000.

ngrok http 8000
from emo_platform import Client, WebHook

client = Client()
# Please replace "YOUR WEBHOOK URL" with the URL forwarded to http://localhost:8000
client.create_webhook_setting(WebHook("YOUR WEBHOOK URL"))

@client.event('message.received')
def message_callback(data):
	print(data)

@client.event('illuminance.changed')
def illuminance_callback(data):
	print(data)

client.start_webhook_event()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

emo-platform-api_sdk-0.1.0.tar.gz (16.0 kB view hashes)

Uploaded Source

Built Distribution

emo_platform_api_sdk-0.1.0-py3-none-any.whl (18.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page