Webhook & Integration Templates

Pre-built integrations for popular AI frameworks

Templates

LangChain Integration
Connect HGM Intelligence API to LangChain agents

Code

from langchain.agents import Tool, AgentExecutor, initialize_agent
from langchain.llms import OpenAI
import requests

# Initialize HGM API client
HGM_API_KEY = "your_api_key_here"
HGM_BASE_URL = "https://api.hgm.io"

def get_arbitrage_opportunities(market: str = "global"):
    """Fetch real-time arbitrage opportunities from HGM"""
    response = requests.get(
        f"{HGM_BASE_URL}/api/scanner/opportunities",
        params={"market": market},
        headers={"Authorization": f"Bearer {HGM_API_KEY}"}
    )
    return response.json()["opportunities"]

def get_market_intelligence(category: str):
    """Get macro signals and market intelligence"""
    response = requests.get(
        f"{HGM_BASE_URL}/api/market-intelligence",
        params={"category": category},
        headers={"Authorization": f"Bearer {HGM_API_KEY}"}
    )
    return response.json()

# Create tools for the agent
tools = [
    Tool(
        name="HGM Arbitrage Scanner",
        func=get_arbitrage_opportunities,
        description="Get real-time arbitrage opportunities across markets"
    ),
    Tool(
        name="HGM Market Intelligence",
        func=get_market_intelligence,
        description="Get macro signals, sentiment, and market analysis"
    )
]

# Initialize agent
llm = OpenAI(temperature=0)
agent = initialize_agent(tools, llm, agent="zero-shot-react-description")

# Use the agent
result = agent.run("Find high-confidence crypto arbitrage opportunities in Asia")
print(result)

Setup Steps

  1. 1.Install required packages: pip install langchain openai requests
  2. 2.Get your HGM API key from the marketplace
  3. 3.Replace "your_api_key_here" with your actual API key
  4. 4.Run the script and let the agent find opportunities