Arcade Python API Client
The Arcade Python library provides convenient access to the Arcade REST API from any Python 3.8+ application. It includes type definitions for all request parameters and response fields, offering both synchronous and asynchronous clients powered by httpx. The library is frequently updated to reflect the latest API changes.
Common errors
-
AttributeError: module 'arcadepy' has no attribute 'open_window'
cause Attempting to use a function from the 'arcade' game development library with the 'arcadepy' API client library.fixThis error indicates you've likely confused the 'arcadepy' API client with the 'arcade' game library. For game development, install and import 'arcade'. For API interaction, use the correct 'arcadepy' client methods like `client.tools.execute()`. -
arcadepy.APIConnectionError: Failed to connect to API
cause The library was unable to establish a network connection to the Arcade API, possibly due to network issues, DNS problems, or incorrect API endpoint configuration.fixCheck your internet connection, verify the API endpoint (if manually configured), and ensure there are no firewall rules blocking access to the Arcade API servers. -
arcadepy.APIStatusError: status_code=401, message='Unauthorized'
cause The provided API key is invalid, expired, or missing, leading to an authentication failure with the Arcade API.fixVerify that your `ARCADE_API_KEY` environment variable is correctly set with a valid, active API key from your Arcade dashboard. -
arcadepy.APIStatusError: status_code=400, message='Bad Request'
cause The request payload (e.g., `tool_name` or `input` parameters for `client.tools.execute`) does not conform to the expected API schema.fixReview the documentation for the specific Arcade tool you are calling and ensure all required parameters are provided with correct data types and formats.
Warnings
- gotcha Do not confuse 'arcadepy' (API client) with 'arcade' (game development library). They are distinct projects with different purposes and APIs.
- gotcha API keys should be managed securely using environment variables (e.g., ARCADE_API_KEY) or a .env file, rather than hardcoding them directly in your source code.
- breaking While generally following SemVer, the library may introduce certain backwards-incompatible changes in minor versions, especially concerning static types or internal implementation details not expected to affect most runtime behavior.
- gotcha For asynchronous usage, import `AsyncArcade` and use `await` with API calls. If using `aiohttp` for improved performance, install `arcadepy[aiohttp]` and explicitly pass `http_client=DefaultAioHttpClient()` to the `AsyncArcade` client.
Install
-
pip install arcadepy -
pip install arcadepy[aiohttp]
Imports
- Arcade
import arcadepy.Arcade
from arcadepy import Arcade
- AsyncArcade
import arcadepy.AsyncArcade
from arcadepy import AsyncArcade
Quickstart
import os
from arcadepy import Arcade
# Ensure ARCADE_API_KEY is set in your environment variables
# e.g., export ARCADE_API_KEY="your_api_key_here"
client = Arcade(
api_key=os.environ.get("ARCADE_API_KEY", "")
)
# Example: Execute a tool (replace with actual tool_name and input)
try:
execute_tool_response = client.tools.execute(
tool_name="Google.Search",
input={
"query": "latest news on AI models"
},
user_id="user@example.com", # Required for many tools requiring user context
)
print(f"Tool execution ID: {execute_tool_response.id}")
print(f"Tool output: {execute_tool_response.output}")
except Exception as e:
print(f"An error occurred: {e}")