Skip to main content

A Python library to interact with Amazon Alexa devices programmatically using refresh tokens

Project description

alexa_api

PyPI - Version PyPI - Python Version License


Table of Contents

Installation

pip install alexa-api
pip install https://github.com/neuhai/alexa_api/archive/refs/tags/v1.0.5.tar.gz
pip install git+https://github.com/neuhai/alexa_api.git

Usage

To use the library, first download from https://github.com/adn77/alexa-cookie-cli/releases/tag/v5.0.1

Run the program and go to http://127.0.0.1:8080 to log in your Amazon account and obtain a refresh token.

Here is a sample usage:

import alexa_api

# Define your Alexa refresh token
refresh_token = "your_refresh_token_here"

# Retrieve the list of Alexa devices
devices = alexa_api.get_device_list(refresh_token)
print(devices)

# Make Alexa speak a custom message
alexa_api.execute_command("speak", "Hello, how can I help you?", refresh_token, "Your Echo Dot")

# Send a text command to Alexa (e.g., open a skill)
alexa_api.execute_command("textcommand", "Alexa, open my demo", refresh_token, "Your Echo Dot")

Features

  • Get a list of Alexa devices: Retrieve all devices associated with an account using the refresh token.
  • Make Alexa Speak: Send a message to Alexa and have it spoken aloud.
  • Execute Commands: Simulate real user usage programmatically by sending text-based commands like open a skill.

API Reference

get_device_list(refresh_token)

Parameters:

  • refresh_token: the refresh token of your account.

Returns:

  • device_list: a list of string. Each string is the device name of an available device.
execute_command(command_type, command_message, refresh_token, device)

Parameters:

  • command_type: the type of the command.
    • Use speak to let Alexa speak out the text.
    • Use textcommand to send a text-based command to Alexa.
  • command_message: the message content of the command.
    • If using speak command: command_message is the text that will be read out by Alexa.
    • If using textcommand command: command_message is the command context that will be sent to Alexa.
  • refresh_token: the refresh token of your account.
  • device: (Optional) the device name of the device that you want the command to execute on. If not specified, the first device in the device list will be used by default.

Returns:

  • status_code: the status code of the HTTP response from Alexa.
  • response_text: the text of the HTTP response from Alexa.

License

alexa-api is distributed under the terms of the MIT license.

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

parcs_alexa_api-1.0.6.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parcs_alexa_api-1.0.6-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file parcs_alexa_api-1.0.6.tar.gz.

File metadata

  • Download URL: parcs_alexa_api-1.0.6.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for parcs_alexa_api-1.0.6.tar.gz
Algorithm Hash digest
SHA256 90001c2a6fe3c6b24753e1118365bdf3500f72adc4cacf52f95882d49546e4fc
MD5 5417e8f9de4340d3ef5f03a80fa40daa
BLAKE2b-256 f1afa58510b1773ad655b9ea847de28a3c569e33a35930b6e44658ecd69b2451

See more details on using hashes here.

File details

Details for the file parcs_alexa_api-1.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for parcs_alexa_api-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ec2b9fd385f4e7c4b6ed754ebb812787f53a224e08c149a8042564496401cd6c
MD5 4aedd4c1cdaa5011816162a350d8518e
BLAKE2b-256 dcc7918a257f62366d753cbd63f2f9a391c1732aff535b2208f36b18244069e4

See more details on using hashes here.

Supported by

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