Skip to main content

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

Metadata

Release files for langchain-purpleflea 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-purpleflea 0.1.1
File Size Uploaded
langchain_purpleflea-0.1.1.tar.gz 15.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-purpleflea 0.1.1
File Interpreter ABI Platform
langchain_purpleflea-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 29.7 kB

Release files / langchain_purpleflea-0.1.1.tar.gz

Download URL langchain_purpleflea-0.1.1.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
70ae1b817d60cf895162b4f5006fefb5c01058b1a9d330874777b4766d5de952
BLAKE2b-256 checksum
How to use checksums
a52603e81eb86c21e9442946b3e986b025818dcda4fbff2ebba57ca12ff12e10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / langchain_purpleflea-0.1.1-py3-none-any.whl

Download URL langchain_purpleflea-0.1.1-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf50069883bf6d74076252cbff99c1220b57d4c79046d2fe53053213f6d35376
BLAKE2b-256 checksum
How to use checksums
8b0afe438e7184ed93562d6f02f395a981e980f35fbdfcec4b134dba45bfe9d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page