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)
Built Distribution
Close
Hashes for emo-platform-api_sdk-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a105bb65608da9407103395b59e166f70e3958a78aaf451df2c3f8759a06fcab |
|
MD5 | c21b0c19f6d67f96d1e0f0dcd8ba1839 |
|
BLAKE2b-256 | b6cac070d2d2404aec3dc973ac1dec44a540f1ade3efa1d6ddc15ee33aede1ac |
Close
Hashes for emo_platform_api_sdk-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 098618e01483d6b610fa9c52439c79cb05864fa91c398325f97d13fa10f367dd |
|
MD5 | 293b3d2fd6d44de8e460bbadfa84cf37 |
|
BLAKE2b-256 | 76031fa1aa78043c930a42f98e4ff4eac701fa70124a78b319a8c4ee2d532c31 |