LangChain tools for Purple Flea — casino, trading, wallet, and domain APIs for AI agents
Project description
langchain-purpleflea
LangChain tools for Purple Flea — casino, trading, wallet, and domain APIs built for autonomous AI agents.
Installation
pip install langchain-purpleflea
What's Inside
| Module | Tools | Description |
|---|---|---|
casino |
7 tools | Provably fair games: coin flip, dice, roulette, crash |
trading |
7 tools | 275+ perpetual futures markets via Hyperliquid (1-50x leverage) |
wallet |
3 tools | Non-custodial HD wallets + best-rate DEX swaps |
domains |
3 tools | Register .ai/.com/.io domains, manage DNS |
toolkit |
all | PurpleFleatoolkit bundles everything |
Quickstart — Toolkit
from langchain_purpleflea import PurpleFleatoolkit
from langchain.agents import initialize_agent, AgentType
from langchain_openai import ChatOpenAI
toolkit = PurpleFleatoolkit(
api_key="sk_live_...",
referral_code="YOUR_CODE", # earn 10-20% of fees from agents you refer
)
tools = toolkit.get_tools()
agent = initialize_agent(
tools,
ChatOpenAI(model="gpt-4o"),
agent=AgentType.OPENAI_FUNCTIONS,
verbose=True,
)
agent.run("Check my casino balance, scan trading markets for opportunities, and list my open positions")
Quickstart — Individual Tools
from langchain_purpleflea import (
CasinoPlay, CasinoGetBalance, CasinoListGames,
TradingOpenPosition, TradingListMarkets, TradingClosePosition, TradingListPositions,
WalletTool, SwapTool, BalanceTool,
DomainSearchTool, DomainPurchaseTool,
)
API_KEY = "sk_live_..."
tools = [
CasinoGetBalance(api_key=API_KEY),
CasinoListGames(api_key=API_KEY),
CasinoPlay(api_key=API_KEY),
TradingListMarkets(api_key=API_KEY),
TradingOpenPosition(api_key=API_KEY),
TradingListPositions(api_key=API_KEY),
TradingClosePosition(api_key=API_KEY),
WalletTool(api_key=API_KEY),
SwapTool(api_key=API_KEY),
BalanceTool(api_key=API_KEY),
DomainSearchTool(api_key=API_KEY),
DomainPurchaseTool(api_key=API_KEY),
]
Tool Reference
Casino Tools
| Tool | name | Description |
|---|---|---|
CasinoPlay |
purpleflea_casino_play |
Play a game round (coin flip, dice, roulette, crash) |
CasinoGetBalance |
purpleflea_casino_get_balance |
Check casino wallet balance |
CasinoDeposit |
purpleflea_casino_deposit |
Deposit funds |
CasinoWithdraw |
purpleflea_casino_withdraw |
Withdraw funds |
CasinoListGames |
purpleflea_casino_list_games |
List available games with house edges |
CasinoGetGame |
purpleflea_casino_get_game |
Get rules and payout info for a game |
CasinoGetGameHistory |
purpleflea_casino_get_game_history |
Retrieve past bets and outcomes |
Trading Tools
| Tool | name | Description |
|---|---|---|
TradingOpenPosition |
purpleflea_trading_open_position |
Open long/short position (1-50x leverage) |
TradingClosePosition |
purpleflea_trading_close_position |
Close a position and realize P&L |
TradingGetPosition |
purpleflea_trading_get_position |
Get unrealized P&L, entry price, margin |
TradingListPositions |
purpleflea_trading_list_positions |
List all open/closed positions |
TradingListMarkets |
purpleflea_trading_list_markets |
Browse 275+ markets with prices and volume |
TradingGetMarket |
purpleflea_trading_get_market |
Get funding rate, OI, price for a market |
TradingGetOrderbook |
purpleflea_trading_get_orderbook |
Get bids/asks depth for a market |
Wallet Tools
| Tool | name | Description |
|---|---|---|
WalletTool |
purpleflea_wallet_create |
Create HD wallet on any chain |
SwapTool |
purpleflea_wallet_swap |
Swap tokens at best DEX rate |
BalanceTool |
purpleflea_wallet_balance |
Check any address's token balances |
Domain Tools
| Tool | name | Description |
|---|---|---|
DomainSearchTool |
purpleflea_domain_search |
Search availability across 500+ TLDs |
DomainPurchaseTool |
purpleflea_domain_purchase |
Register a domain |
DNSTool |
purpleflea_domain_add_dns_record |
Add A/CNAME/TXT/MX DNS records |
Referral Program
Every Purple Flea product has a referral program. Agents earn:
- Casino: 10% of referred agents' net losses
- Trading: 20% of referred agents' trading fees — forever
- Wallet: 10% of referred agents' swap fees
Pass referral_code to PurpleFleatoolkit or embed it in WalletTool/DomainPurchaseTool calls to activate.
CrewAI Example
from crewai import Agent, Task, Crew
from langchain_purpleflea import PurpleFleatoolkit
tools = PurpleFleatoolkit(api_key="sk_live_...").get_tools()
trader = Agent(
role="Autonomous Trader",
goal="Monitor 275 markets and execute profitable perpetual futures trades",
backstory="You are a quantitative trader with access to all Hyperliquid markets via Purple Flea.",
tools=tools,
)
task = Task(
description="Identify the top trending market and open a $100 long position with 5x leverage.",
expected_output="Position ID, entry price, and liquidation price.",
agent=trader,
)
Crew(agents=[trader], tasks=[task]).kickoff()
Links
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_purpleflea-0.1.1.tar.gz.
File metadata
- Download URL: langchain_purpleflea-0.1.1.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70ae1b817d60cf895162b4f5006fefb5c01058b1a9d330874777b4766d5de952
|
|
| MD5 |
0b73d242c6e8515d7c8dc04e53a78056
|
|
| BLAKE2b-256 |
a52603e81eb86c21e9442946b3e986b025818dcda4fbff2ebba57ca12ff12e10
|
File details
Details for the file langchain_purpleflea-0.1.1-py3-none-any.whl.
File metadata
- Download URL: langchain_purpleflea-0.1.1-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf50069883bf6d74076252cbff99c1220b57d4c79046d2fe53053213f6d35376
|
|
| MD5 |
b0516e4f19eeef40ea803483a03b9b88
|
|
| BLAKE2b-256 |
8b0afe438e7184ed93562d6f02f395a981e980f35fbdfcec4b134dba45bfe9d5
|