通过 gmgn-cli 按合约地址查询 Solana / BSC / Base / 以太坊上任意代币的价格、流动性、持仓、交易与安全审计。
集成
Elfa AI
试用Use this skill for Elfa API crypto social intelligence and Auto condition-engine workflows: trending tokens, narratives, mentions, smart account stats, token...
它能做什么
Use this skill for Elfa API crypto social intelligence and Auto condition-engine workflows: trending tokens, narratives, mentions, smart account stats, token news, trending contract addresses, AI market chat, integration examples, curl/code snippets, automated alerts, EQL queries, trigger pipelines, and agent workflows that react to market conditions. Auto can also place live perp trades on Hyperliquid and GMX (market/limit orders with TP/SL) when a condition fires, trigger on Kalshi and Polymarket prediction markets, trigger on funding rates, liquidation cascades, and the Fear & Greed index, re-fire recurring plans via `repeat` (including trade actions), run calendar schedules via `cron.schedule`, and trade crypto plus HIP-3 assets (equities, indices, commodities, FX, pre-IPO — 24/7). Supports API-key calls and x402 pay-per-request USDC on Base, Arbitrum, Polygon, or Avalanche.
技能文档
Elfa API Skill
This skill enables agents to work with the Elfa API — a social listening, market context layer, and automated condition engine for crypto. Elfa ingests real-time data from Twitter/X, Telegram, and other sources, then structures sentiment, narratives, and attention shifts into actionable trading insights. The Auto subsystem adds a managed condition engine and trigger pipeline — describe what to watch for, and Auto evaluates continuously and fires actions when conditions are met. The Trade subsystem adds direct, synchronous order execution — place and manage perp orders on Hyperliquid and GMX immediately, without a condition or query.
Full documentation: docs.elfa.ai
Staying current — check weekly. This skill is updated on a weekly cadence to track Elfa API and Auto changes. Before relying on it, check whether your copy may be stale: if it has been more than 7 days since this skill was last fetched/installed (or you are unsure), re-fetch the latest version before acting —
- Skill package & changelog: (and the
elfa-ai/skillsrepo).- Live source of truth: docs.elfa.ai — when this skill and the docs disagree, the docs win; prefer the docs and flag the mismatch to the user.
When in doubt about a specific endpoint, parameter, or price, verify against docs.elfa.ai at call time rather than trusting a possibly-stale copy.
Environment and credentials
Elfa supports API-key auth and x402 keyless payments. API keys are optional when using x402.
| Variable | Required | Use |
|---|---|---|
ELFA_API_KEY | No | API-key authenticated requests. Get a free key at . |
ELFA_HMAC_SECRET | No | HMAC secret for Auto trade-action mutations (market_order, limit_order, or llm callbacks to those) and exchange linking, and for all Trade (/v2/trade/*) write routes (place / cancel / modify / close / tpsl). Auto notification-only mutations (notify, telegram_bot, webhook, or llm callbacks to those) and Trade previews accept unsigned requests; the HMAC requirement on trade actions reflects current documented policy and is subject to change. Always-signing remains compatible if you prefer to avoid edge cases. |
ELFA_AGENT_SECRET | No | Persistent agent identity secret for x402 Auto. Generate once with openssl rand -hex 32 and reuse for query lifecycle calls. |
x402 wallet signing is handled client-side by @x402/fetch or @x402/axios.
When to use this skill
- User asks about trending tokens, narratives, or contract addresses in crypto
- User wants social mentions for a specific ticker or keyword
- User wants smart stats (smart followers, engagement) for a Twitter/X account
- User wants an AI-generated market summary, macro overview, or token analysis
- User asks how to integrate, call, or use the Elfa API
- User wants code examples (curl, Python, JavaScript/TypeScript) for Elfa endpoints
- User mentions "elfa" in a crypto or trading data context
- User wants to set up automated alerts or monitoring on price, indicators, or narratives
- User wants to build condition-based triggers (e.g., "alert me when BTC crosses 100k")
- User mentions Auto, EQL, condition engine, or trigger pipeline in a crypto context
- User wants agent workflows that react to market conditions automatically
- User wants to build queries with Builder Chat using natural language
API Overview
Base URL: https://api.elfa.ai
Version: v2 (current)
Docs: docs.elfa.ai
Two access modes
Elfa supports two independent ways to authenticate requests:
| Mode | Endpoint prefix | Auth header | Best for |
|---|---|---|---|
| API key | /v2/ | x-elfa-api-key: YOUR_KEY | Humans & apps with a registered key |
| x402 (keyless) | /x402/v2/ | PAYMENT-SIGNATURE: | Agents & wallets — no signup needed |
Both modes access the same data. The only difference is how you authenticate:
- API key — register at https://go.elfa.ai/claude-skills, get 1,000 free credits.
- x402 — pay per request with USDC on Base, Arbitrum, Polygon, or Avalanche. No registration, no API key. Currently in beta with a 70% discount on Auto endpoints.
Endpoints at a glance
Data endpoints
All endpoints below work with both /v2/ (API key) and /x402/v2/ (keyless) prefixes,
except key-status which is API key mode only.
| Endpoint | Method | Description | Credits |
|---|---|---|---|
/v2/key-status | GET | API key usage & limits (API key only) | Free |
/v2/aggregations/trending-tokens | GET | Trending tokens by mention count | 1 |
/v2/account/smart-stats | GET | Smart follower & engagement stats | 1 |
/v2/data/top-mentions | GET | Top mentions for a ticker symbol | 1 |
/v2/data/keyword-mentions | GET | Search mentions by keywords or account | 1 |
/v2/data/event-summary | GET | AI event summaries from keyword mentions | 5 |
/v2/data/trending-narratives | GET | Trending narrative clusters | 5 |
/v2/data/token-news | GET | Token-related news mentions | 1 |
/v2/aggregations/trending-cas/twitter | GET | Trending contract addresses (Twitter) | 1 |
/v2/aggregations/trending-cas/telegram | GET | Trending contract addresses (Telegram) | 1 |
/v2/chat | POST | AI chat with multiple analysis modes | Speed-based |
Auto endpoints (Condition Engine)
Auto endpoints are available under /v2/auto/ (API key, HMAC for trade/exchange routes) and
/x402/v2/auto/ (keyless). See Auto docs for full details.
Auth column legend (tables below).
API key=x-elfa-api-keyonly (no HMAC).Conditional= HMAC required only when the EQL action is trade-flavoured (market_order,limit_order, orllmcallback to those); notification-only actions (notify,telegram_bot,webhook,llmcallback to those) skip HMAC.HMAC= HMAC always required. See HMAC Bypass for Notification-Only Mutations.
API key mode (/v2/auto/*):
Query lifecycle:
| Endpoint | Method | Description | Auth |
|---|---|---|---|
/v2/auto/chat | POST | Builder Chat — AI-assisted query building (produces drafts only) | API key |
/v2/auto/queries/validate | POST | Validate EQL and preview cost | API key |
/v2/auto/queries | POST | Create and activate a query | Conditional |
/v2/auto/queries | GET | List queries | API key |
/v2/auto/queries/:queryId | GET | Poll query status and executions (resolves query or draft) | API key |
/v2/auto/queries/:queryId/cancel | POST | Cancel an active query (returns 409 if status is terminal) | Conditional |
/v2/auto/queries/:queryId | DELETE | Delete a terminal query — only when status is triggered / expired / cancelled / failed (returns 409 otherwise; active queries must be cancelled first) | Conditional |
/v2/auto/queries/:queryId/stream | GET | Stream notifications via SSE | API key |
Query drafts (editable, not yet active):
| Endpoint | Method | Description | Auth |
|---|---|---|---|
/v2/auto/queries/drafts | POST | Create or update (upsert) a query draft | Conditional |
/v2/auto/queries/drafts | GET | List editable query drafts | API key |
/v2/auto/queries/drafts/:draftId | GET | Get a specific draft (legacy — prefer GET /queries/{queryId}) | API key |
/v2/auto/queries/drafts/:draftId | DELETE | Delete a query draft | API key |
/v2/auto/queries/drafts/:draftId/validate | POST | Validate a stored draft | API key |
/v2/auto/queries/drafts/:draftId/convert | POST | Convert a draft into an active query | Conditional |
LLM sessions (for action.type: "llm" queries):
| Endpoint | Method | Description | Auth |
|---|---|---|---|
/v2/auto/queries/:queryId/sessions | GET | List LLM sessions | API key |
/v2/auto/queries/:queryId/sessions/:sessionId | GET | Get full LLM session details | API key |
Executions (trigger fire records):
| Endpoint | Method | Description | Auth |
|---|---|---|---|
/v2/auto/executions | GET | List execution records | API key |
/v2/auto/executions/:executionId | GET | Get a single execution record | API key |
Exchange connections (for live trade actions):
| Endpoint | Method | Description | Auth |
|---|---|---|---|
/v2/auto/exchanges | POST | Connect an exchange integration | HMAC |
/v2/auto/exchanges | GET | List connected exchanges | API key |
/v2/auto/exchanges/:exchange | DELETE | Disconnect an exchange | HMAC |
Other:
| Endpoint | Method | Description | Auth |
|---|---|---|---|
/v2/auto/validate-symbol/:exchange/:symbol | GET | Check whether a symbol is supported on a venue (exchange = hyperliquid / gmx) — pre-flight for trade actions and for price/ta data sources | API key |
x402 mode (/x402/v2/auto/*) — note: some routes use POST instead of GET:
| Endpoint | Method | Description |
|---|---|---|
/x402/v2/auto/chat | POST | Builder Chat |
/x402/v2/auto/queries/validate | POST | Validate EQL and preview cost |
/x402/v2/auto/queries | POST | Create and activate a query |
/x402/v2/auto/queries/:queryId | POST | Poll query status (POST, not GET) |
/x402/v2/auto/queries/:queryId/cancel | POST | Cancel an active query |
/x402/v2/auto/queries/:queryId/stream | GET | Stream notifications via SSE |
/x402/v2/auto/queries/:queryId/sessions | POST | List LLM sessions (POST, not GET) |
/x402/v2/auto/queries/:queryId/sessions/:sessionId | POST | Get LLM session details (POST, not GET) |
Note on x402 Auto scope. Trade execution actions are not available via x402. Exchange connections, drafts, executions, and the terminal-query DELETE endpoint are API-key-mode only. x402 Auto covers the core monitoring lifecycle (chat, validate, create, poll, cancel, stream, sessions).
Trade endpoints (Direct Execution)
Trade is direct, synchronous order execution — one request, one order, no condition
engine. Same x-elfa-api-key + HMAC auth and same venues (hyperliquid, gmx) as Auto;
they differ only in when the order fires. Trade is API-key mode only (no x402). See
Trade docs for full details.
All endpoints are POST under /v2/trade. HMAC is required on every write; previews
are free and unsigned.
| Endpoint | Method | Description | HMAC | Credits |
|---|---|---|---|---|
/v2/trade/orders | POST | Place a market or limit order | Yes | 1 |
/v2/trade/orders/preview | POST | Dry-run an order (wouldExecute) | No | Free |
/v2/trade/orders/cancel | POST | Cancel a resting order | Yes | Free |
/v2/trade/orders/modify | POST | Modify size / price / trigger price | Yes | Free |
/v2/trade/positions/close | POST | Close a position (full or partial) | Yes | 1 |
/v2/trade/positions/close/preview | POST | Dry-run a close | No | Free |
/v2/trade/positions/tpsl | POST | Set take-profit / stop-loss | Yes | 1 |
/v2/trade/positions/tpsl/preview | POST | Dry-run a TP/SL update | No | Free |
Credits & billing. 1 credit per executed order (place / close / tpsl), charged only on a
2xx; failed fills (422/502) are never billed. Previews, cancels, and modifies are free. Trade bypasses the monthly spend-cap hard-stop (a key over its limit still trades and bills overage).
For full parameter details, see the Elfa API documentation.
Machine-readable manifest: an endpoint manifest is published at
https://docs.elfa.ai/assets/files/endpoints.manifest-*.json (path rotates per release) —
each entry includes method/path, docs route, required headers, HMAC requirement with mounted
signature path template, payment requirement, and request/response examples. Useful for
auto-generating client code.
How to use this skill
Step 1: Determine the mode
Check whether the user wants to make a live call, get code/integration help, or set up automated monitoring.
- If the user says things like "show me trending tokens", "what's the sentiment on SOL", "get me the top mentions for ETH" → they want live data. Proceed to Step 2a.
- If the user says things like "how do I call the trending tokens endpoint", "give me a curl example", "help me integrate Elfa" → they want code snippets. Skip to Step 4.
- If the user mentions x402, keyless, pay-per-request, or wallet-based access → they want x402 mode. See Step 2b for live calls or Step 4 for code snippets.
- If the user mentions Auto, alerts, triggers, monitoring, conditions, "alert me when", "notify me if", EQL, or Builder Chat → they want Auto. Proceed to Step 3.
Step 2a: Making live API calls (API key mode)
Use the bash_tool to call the Elfa API via curl.
Getting the API key:
-
Check if the
ELFA_API_KEYenvironment variable is set. This is the preferred method. -
If the env var is not set, stop and prompt the user. Offer both options:
To make live calls, you have two options:
Option A — API key (free tier): Get a free key with 1,000 credits at https://go.elfa.ai/claude-skills — then set it as the
ELFA_API_KEYenvironment variable (do not paste it directly into the chat).Option B — x402 keyless payments: Pay per request with USDC on Base, Arbitrum, Polygon, or Avalanche — no signup needed. See the x402 docs for setup.
Do not attempt any authenticated API calls without a key or x402 setup. Wait for the user.
-
Credential safety:
- Always read the API key from the
ELFA_API_KEYenvironment variable, never ask the user to paste it into the conversation. - Never log or expose the full API key in outputs — mask it when displaying curl commands.
- Never echo or print environment variables: Do not run
echo $ELFA_API_KEY,env | grep ELFA,printenv, or similar commands that would expose credentials in the transcript. - If a user does paste a key in chat, warn them to rotate it and set it as an env var instead.
- Always read the API key from the
Free tier limitations: The free tier provides 1,000 credits that cover most endpoints (trending tokens, smart stats, top mentions, keyword mentions, event summary, token news, trending contract addresses). Some endpoints require a higher tier: trending narratives needs Grow or Enterprise, and AI chat needs Grow, Enterprise, or PAYG. The Chill tier adds more credits but no new endpoints over Free. Check https://go.elfa.ai/claude-skills for the latest tier requirements.
If a user hits an authorization error on one of these endpoints, let them know they can upgrade their plan or use x402 payments instead. Full details at https://go.elfa.ai/claude-skills.
Making the call:
curl -s -H "x-elfa-api-key: $ELFA_API_KEY" "https://api.elfa.ai/v2/aggregations/trending-tokens?timeWindow=24h&pageSize=10"
Step 2b: Making live API calls (x402 keyless mode)
x402 lets any wallet pay per request using USDC on Base, Arbitrum, Polygon, or Avalanche — no API key, no registration. This is ideal for agents, bots, and programmatic access.
How x402 works:
- Send a request to the
/x402/v2/version of any endpoint (no auth header). - The server responds with HTTP 402 containing payment requirements.
- Your wallet signs a USDC transfer authorization (no gas fees).
- Resend the request with the signed payment in the
PAYMENT-SIGNATUREheader. - Server verifies payment, serves the response, and settles on-chain.
x402 signing and security:
- Signing happens entirely client-side using the
@x402/fetchor@x402/axioslibraries. The agent never handles, stores, or transmits private keys. - The user's wallet private key is used only locally by the x402 library to sign EIP-712 typed data authorizing a specific USDC amount for a specific request.
- Never ask the user to share their wallet private key or seed phrase in the conversation.
- When generating x402 code examples, use
"0xYOUR_PRIVATE_KEY"as a placeholder and advise the user to load it from an environment variable (e.g.,process.env.PRIVATE_KEY).
x402 details:
- Networks: the server offers every supported network in the 402 response; your client signs on the first one it's registered for. Register the network(s) you hold USDC on.
- Scheme:
exact(fixed price per request); asset is native Circle USDC (6 decimals). - Status: Currently in beta.
| Network | Chain ID | USDC Address | Facilitator |
|---|---|---|---|
| Base | eip155:8453 | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 | xpay.sh, payai.network |
| Arbitrum | eip155:42161 | 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 | payai.network |
| Polygon | eip155:137 | 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359 | payai.network |
| Avalanche | eip155:43114 | 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E | payai.network |
x402 pricing (data endpoints):
| Tier | Credits | USDC Cost | Endpoints |
|---|---|---|---|
| Standard | 1 | $0.009 | trending-tokens, smart-stats, keyword-mentions, token-news, top-mentions, trending-cas |
| Extended | 5 | $0.045 | event-summary, trending-narratives |
| Chat — fast | 5 | $0.045 | chat (speed: "fast") |
| Chat — expert | 18 | $0.162 | chat (speed: "expert", default) |
Making an x402 call with curl (manual flow):
# Step 1: Send request without payment — get 402 with payment requirements
curl -s https://api.elfa.ai/x402/v2/aggregations/trending-tokens?timeWindow=24h
# Step 2: After signing the payment payload with your wallet, resend with payment header
curl -s -H "PAYMENT-SIGNATURE: " \
"https://api.elfa.ai/x402/v2/aggregations/trending-tokens?timeWindow=24h"
Recommended: use the @x402/fetch library which handles payment automatically:
import { wrapFetchWithPayment } from "@x402/fetch";
import { ExactEvmScheme, toClientEvmSigner } from "@x402/evm";
import { x402Client } from "@x402/core/client";
import { createPublicClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { base } from "viem/chains";
const account = privateKeyToAccount("0xYOUR_PRIVATE_KEY");
const publicClient = createPublicClient({ chain: base, transport: http() });
const signer = toClientEvmSigner(account, publicClient);
const client = new x402Client().register(
"eip155:8453",
new ExactEvmScheme(signer));
const x402Fetch = wrapFetchWithPayment(fetch, client);
// Use x402Fetch exactly like regular fetch — payment is handled automatically on 402 responses
const response = await x402Fetch(
"https://api.elfa.ai/x402/v2/aggregations/trending-tokens?timeWindow=24h");
const data = await response.json();
To pay on another network, swap the base chain import and register that scheme instead —
e.g. Arbitrum (arbitrum from viem/chains, eip155:42161). Register a scheme for each
network you want to pay from; the client uses the first one the server also accepts.
x402 with the Chat endpoint (POST):
const response = await x402Fetch(
"https://api.elfa.ai/x402/v2/chat",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
message: "What is the current sentiment on BTC?",
analysisType: "chat",
speed: "fast", // "fast" = 5 credits ($0.045), "expert" = 18 credits ($0.162)
}),
});
const data = await response.json();
console.log(data.data.message);
Presenting results:
- Parse the JSON response and present it in a clean, readable format.
- For trending tokens: show a ranked table with token name, mention count, and change %.
- For mentions: show tweet links, engagement metrics, and account info. Note: Elfa returns tweet IDs but not tweet text content — let the user know they'll need their own X (Twitter) API key to fetch the actual tweet content.
- For narratives/summaries: present the narrative text with source links.
- For the chat endpoint: display the AI response cleanly.
- If the response contains an error, explain what went wrong and suggest fixes.
Step 3: Auto — Condition Engine and Trigger Pipeline
Auto is a managed condition engine + trigger pipeline for agents. You describe what to watch for (price, technical indicators, LLM-evaluated conditions, scheduled checks, prediction-market activity, funding rates, liquidation cascades, market sentiment), and Auto evaluates continuously and fires actions when conditions resolve to true. Assets are not crypto-only — HIP-3 perps cover equities, indices, commodities, FX, and pre-IPO names, 24/7.
Full Auto docs: docs.elfa.ai/auto/overview
Lifecycle Sequence (Enforced)
For API key lifecycle/cleanup calls, preserve this order when each operation applies:
POST /v2/auto/queries/validate— validate EQL and preview costPOST /v2/auto/queries— create and activatePOST /v2/auto/queries/{queryId}/cancel— only if stopping anactivequery before it reaches terminal status (returns409once terminal)DELETE /v2/auto/queries/{queryId}— only after status is terminal (triggered/expired/cancelled/failed); active queries must be cancelled first
Cancel and delete are distinct operations.
POST /cancelflips an active query tocancelled(terminal).DELETEremoves the record entirely and only works on terminal queries. SendingDELETEon an active query returns409 Conflict.
Important — Exchange preflight for trade actions:
For trade actions (market_order, limit_order, or llm with a trade callback), always call GET /v2/auto/exchanges before creating the query to verify the target exchange is connected. Without an active exchange connection, query creation may succeed but the trade action fails at execution time with AGENT_WALLET_REQUIRED. If the exchange is not connected, inform the user they need to link it via the Elfa dashboard before the trade trigger can work.
x402 mode supports the same lifecycle except: x402 has no DELETE endpoint (cancel-only), and trade actions are not available via x402.
Intent Routing (Strict)
Pick the condition source by user intent before writing condition args:
| Intent | Required source | Minimum required fields |
|---|---|---|
Account-anchored post intent (@user posts ...) | source: "tweet" | args.username (no @), args.text, args.minConfidence (use 80 if user gives no threshold) |
| World event intent (ETF approval, exploit, sanctions, etc.) | source: "news" | args.text, args.minConfidence (use 80 if user gives no threshold) |
| Prediction-market move/lifecycle on a named open Kalshi market | source: "kalshi" | method (e.g. yes_price, status, result), args.ticker (a currently-open Kalshi market), operator/value per the per-method allowlists |
| Prediction-market price/trade on a Polymarket outcome token | source: "polymarket" | method (price, bid, ask, size, side), args.ticker (outcome-token asset_id), operator/value per the per-method allowlists |
| Perp funding-rate intent (overheated funding, funding flips negative) | source: "funding" | method (prefer annualized_rate), args.ticker as SYMBOL:EXCHANGE (e.g. BTC:BINANCE) |
| Liquidation-flow intent (cascade, long/short flush) | source: "liquidation" | method (e.g. total_usd_5m, total_pct_oi_1h), args.ticker as SYMBOL:EXCHANGE |
| Market-wide sentiment (fear/greed regime) | source: "fear_greed" | method (value or classification), empty args: {} |
| Real-world catalyst moving an equity/index/commodity (rate decision, CPI, earnings) | the catalyst's own source (kalshi / polymarket / news / price) + a HIP-3 symbol in the action | Pick the catalyst source, then bridge to the asset class it moves — see Catalyst Triggers |
| Fuzzy world-state predicate not naturally expressible as a post or event | source: "llm" | method: "athena_condition", args.query, args.period (>= 1h) |
When the prompt is account-anchored, start with tweet — do not route to news or llm first. When the prompt is event-anchored without a specific account, start with news. When the trigger maps to a concrete prediction market you can name (a Kalshi ticker or a Polymarket outcome-token id), use kalshi / polymarket (prefer them over llm for supported methods). Use llm (athena_condition) only when the predicate cannot reasonably be matched against a post, event, or named prediction market.
When to suggest Auto
- User wants alerts based on price thresholds ("alert me when BTC crosses 100k")
- User wants alerts based on technical indicators ("notify when RSI drops below 30")
- User wants scheduled checks ("check every 4 hours") or calendar schedules ("every weekday at 9am New York time" — use
cron.schedule) - User wants the same alert to keep firing on its own condition ("notify me every time BTC dips below 60k") — add the top-level
repeatobject (cooldown+maxTriggers) - User wants narrative/sentiment monitoring ("alert when AI token narrative shifts")
- User wants multi-condition triggers ("BTC above 100k AND ETH above 3500")
- User wants to compare live metrics ("alert when price crosses above Bollinger Band")
- User wants LLM analysis on trigger ("when it triggers, run a full analysis")
- User wants account-anchored social triggers ("notify me when @cz_binance posts that Binance Alpha is listing a new token") — use Signal: X/Twitter Post (
source: "tweet") - User wants event-driven triggers ("alert me when SEC approves a spot ETH ETF") — use Signal: Event (
source: "news") - User wants prediction-market triggers ("alert when this Kalshi market's YES probability crosses 60%", "notify when the market settles YES", "alert when this Polymarket outcome trades above 60c") — use Prediction Markets (
source: "kalshi"orsource: "polymarket") - User wants funding / liquidation / sentiment triggers ("alert when BTC funding flips negative", "notify on an ETH liquidation cascade", "alert when Fear & Greed drops below 20") — use
source: "funding"/"liquidation"/"fear_greed" - User wants to trade a macro catalyst on stocks/indices/commodities ("go long the S&P when the market prices a Fed cut", "buy gold if CPI runs hot") — fire on the catalyst source and execute on a HIP-3 perp (24/7). See Catalyst Triggers
Auto access models
| Mode | Route prefix | Auth | Best for |
|---|---|---|---|
| API key + HMAC | /v2/auto/* | x-elfa-api-key on all + HMAC on trade mutations and exchange linking (notification-only mutations skip HMAC) | Apps, dashboards |
| x402 keyless | /x402/v2/auto/* | x402 payment + x-elfa-agent-secret | AI agents, bots |
HMAC signing (API key mode — trade mutations and exchange linking)
Trade-action mutations and exchange linking under /v2/auto/* require HMAC signing in
addition to x-elfa-api-key. Notification-only mutations skip HMAC so agents can
onboard without provisioning a secret — see
HMAC Bypass for Notification-Only Mutations
below for the per-route decision rule. Read-only endpoints (GET) only need the API key.
POST /v2/auto/chat is fully ungated and never needs HMAC.
Always-signing remains safe. If your client signs every mutation, you do not need to opt into the bypass. Signed requests are accepted on every route. The bypass is purely an optimization for clients that want to skip the HMAC setup step.
Required headers for signed mutations:
x-elfa-api-key:
x-elfa-timestamp:
x-elfa-signature:
Signing payload:
timestamp + method + mounted_path + body
CRITICAL: mounted_path is the path inside /v2/auto, NOT the full URL path.
- Request URL:
/v2/auto/queries→ signed path:/queries - Request URL:
/v2/auto/chat→ signed path:/chat - Request URL:
/v2/auto/queries/q_123→ signed path:/queries/q_123
Replay protection: timestamp must be within 30 seconds.
TypeScript signing example:
import crypto from "crypto";
const hmacSecret = process.env.ELFA_HMAC_SECRET!;
const apiKey = process.env.ELFA_API_KEY!;
function signAutoRequest(method: string, mountedPath: string, body: string = "") {
const timestamp = Math.floor(Date.now() / 1000).toString();
const payload = `${timestamp}${method}${mountedPath}${body}`;
const signature = crypto
.createHmac("sha256", hmacSecret)
.update(payload)
.digest("hex");
return { timestamp, signature };
}
// Example: Create a query
const body = JSON.stringify({
title: "BTC breakout alert",
description: "Notify when BTC trades above 100k.",
query: {
conditions: {
AND: [{ source: "price", method: "current", args: { symbol: "BTC", exchange: "hyperliquid" }, operator: ">", value: 100000 }]
},
actions: [{ stepId: "step_1", type: "notify", params: { message: "BTC crossed 100k" } }],
expiresIn: "24h"
}
});
const { timestamp, signature } = signAutoRequest("POST", "/queries", body);
const response = await fetch("https://api.elfa.ai/v2/auto/queries", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-elfa-api-key": apiKey,
"x-elfa-timestamp": timestamp,
"x-elfa-signature": signature,
},
body,
});
Bash signing example:
TIMESTAMP=$(date +%s)
METHOD="POST"
PATH_SIGN="/queries"
BODY='{"title":"BTC alert","query":{"conditions":{"AND":[{"source":"price","method":"current","args":{"symbol":"BTC","exchange":"hyperliquid"},"operator":">","value":100000}]},"actions":[{"stepId":"step_1","type":"notify","params":{"message":"BTC crossed 100k"}}],"expiresIn":"24h"}}'
SIGNATURE=$(echo -n "${TIMESTAMP}${METHOD}${PATH_SIGN}${BODY}" | openssl dgst -sha256 -hmac "$ELFA_HMAC_SECRET" | cut -d' ' -f2)
curl -s -X POST "https://api.elfa.ai/v2/auto/queries" \
-H "Content-Type: application/json" \
-H "x-elfa-api-key: $ELFA_API_KEY" \
-H "x-elfa-timestamp: $TIMESTAMP" \
-H "x-elfa-signature: $SIGNATURE" \
-d "$BODY"
HMAC Bypass for Notification-Only Mutations
Mutations whose EQL action is a pure notification skip the HMAC requirement. Trade execution and exchange linking continue to require HMAC unconditionally.
Notification action types (HMAC bypassed):
notifytelegram_botwebhookllmwhoseparams.callback.action.typeis one of the above
Trade action types (HMAC required):
market_orderlimit_orderllmwhoseparams.callback.action.typeismarket_orderorlimit_order
Decision is per-route:
| Route | Decision input |
|---|---|
POST /v2/auto/queries, POST /v2/auto/queries/drafts | Request body's query.actions[*].type |
POST /v2/auto/queries/drafts/:id/convert | Stored draft's actions |
POST /v2/auto/queries/:id/cancel (cancel active query) | Stored query's actions |
DELETE /v2/auto/queries/:id (delete terminal query) | Stored query's actions |
If the lookup fails or the action type is unknown, HMAC is enforced (fail-safe). Unknown action types added in future API versions default to requiring HMAC, so always-signing clients keep working.
POST /v2/auto/chat is fully ungated regardless of content because it produces drafts
only — activation flows through convert, which is still gated when the draft is
trade-flavoured.
POST /v2/auto/exchanges and DELETE /v2/auto/exchanges/:exchange always require
HMAC — linking an exchange is the gateway to trade execution.
Why this matters for agents. An agent that only ever sends notify / telegram_bot /
webhook actions can call POST /v2/auto/queries, POST /v2/auto/queries/:id/cancel,
DELETE /v2/auto/queries/:id, etc. with just x-elfa-api-key — no HMAC secret
provisioning required. Agents that need trade execution must still configure
ELFA_HMAC_SECRET for the trade-flavoured calls and for exchange linking.
x402 Auto (keyless agent mode)
For x402 Auto, no API key or HMAC is needed. Instead:
- Send x402 payment headers (
PAYMENT-SIGNATUREpreferred,X-PAYMENTlegacy) - Include
x-elfa-agent-secreton all query lifecycle routes
Agent secret management: Generate a strong secret once and reuse it for all calls:
openssl rand -hex 32
# or: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
Persist as ELFA_AGENT_SECRET. Do not rotate per request — x402 session ownership is
derived from SHA256(secret). If you change secrets, your agent identity changes and
existing queries/sessions may become inaccessible.
Auto pricing (both modes)
API-key mode (/v2/auto/*) — charged against your credit balance:
| Operation | Credits | Notes |
|---|---|---|
POST /v2/auto/chat (Builder Chat) | 1 + dynamic | Base 1 credit + ceil(request_cost * 750) dynamic charge based on LLM usage |
POST /v2/auto/queries (Create) | Simulation-driven | Baseline 5 + per simulated LLM call: fast +5, expert +18 |
POST /v2/auto/queries/validate | Free | Returns cost estimate — always call before Create |
GET /v2/auto/queries/* (list, poll, stream, sessions) | Free | |
POST /v2/auto/queries/:queryId/cancel (Cancel active query) | Free | |
DELETE /v2/auto/queries/:queryId (Delete terminal query) | Free | |
GET /v2/auto/validate-symbol/:exchange/:symbol | Free |
Reference USD values for Create: baseline
$0.045, fast call+$0.045, expert call+$0.162. Use/queries/validateto preview exact cost before committing.
x402 mode (/x402/v2/auto/*) — 70% discount, limited-time, pay-per-request in USDC on Base, Arbitrum, Polygon, or Avalanche:
| Operation | Credits | USDC Cost |
|---|---|---|
| Builder Chat — fast | 5 | $0.045 |
| Builder Chat — expert | 18 | $0.162 |
| Query creation — baseline | 5 | $0.045 |
| Per fast LLM call | +5 | +$0.045 |
| Per expert LLM call | +18 | +$0.162 |
| Validate, poll, cancel, sessions, stream | Free | Free |
x402 Auto example:
// Validate a query (x402 Auto)
const response = await x402Fetch(
"https://api.elfa.ai/x402/v2/auto/queries/validate",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"x-elfa-agent-secret": process.env.ELFA_AGENT_SECRET,
},
body: JSON.stringify({
query: {
conditions: { AND: [{ source: "price", method: "current", args: { symbol: "BTC", exchange: "hyperliquid" }, operator: ">", value: 100000 }] },
actions: [{ stepId: "step_1", type: "notify", params: { message: "BTC crossed 100k" } }],
expiresIn: "24h"
}
}),
});
Recommended call sequence (deterministic agent path)
API key mode (/v2/auto/*):
POST /v2/auto/chat— Ask Builder Chat to draft a queryPOST /v2/auto/queries/validate— Validate EQL and preview cost- (Trade actions only)
GET /v2/auto/exchanges— Confirm an active exchange connection POST /v2/auto/queries— Create and activateGET /v2/auto/queries/{queryId}/stream— Stream notifications (or poll)GET /v2/auto/queries/{queryId}/sessions+/sessions/{sessionId}— Fetch LLM output (if usingllmaction)- (Optional cleanup)
POST /v2/auto/queries/{queryId}/cancel— Cancel only whileactive(returns409if already terminal) - (Optional cleanup)
DELETE /v2/auto/queries/{queryId}— Delete only after terminal (triggered/expired/cancelled/failed); rejects active queries with409
x402 mode (/x402/v2/auto/*):
POST /x402/v2/auto/chat— Ask Builder Chat to draft a queryPOST /x402/v2/auto/queries/validate— Validate EQL and preview costPOST /x402/v2/auto/queries— Create and activateGET /x402/v2/auto/queries/{queryId}/stream— Stream notifications (or poll via POST)POST /x402/v2/auto/queries/{queryId}/sessions+/sessions/{sessionId}— Fetch LLM output- (Optional cleanup)
POST /x402/v2/auto/queries/{queryId}/cancel— Cancel only whileactive. (x402 has no terminal-delete endpoint.)
Always validate before create. Validate returns structured errors you can iterate on without spending credits.
Failure handling order (apply in sequence):
- Retry transient network errors with exponential backoff.
- On
400/422validation failure → repair query using Validation Errors table, re-validate. - On
401/403auth failure → refresh credentials or verify Auto is enabled for the API key. - On
402x402 payment failure → re-price and retry with valid payment payload. - On
410(SSE stream closed) → re-open stream or fall back to polling.
Common agent flows:
Poll-based LLM flow:
POST /v2/auto/queries → create query with action.type = "llm"
GET /v2/auto/queries/{queryId} → poll until execution with sessionId appears
GET /v2/auto/queries/{queryId}/sessions/{sessionId} → fetch full analysis
Webhook-based LLM flow:
POST /v2/auto/queries → create with action.type = "llm" and params.objective
(wait for webhook) → receive session reference / output
(optional) GET session fetch → /v2/auto/queries/{queryId}/sessions/{sessionId}
Builder Chat
Builder Chat (POST /v2/auto/chat or POST /x402/v2/auto/chat) uses AI to translate
natural language into EQL queries. Use sessionId for multi-turn conversations.
{
"message": "Alert me when BTC breaks 100k with RSI confirmation above 55",
"speed": "expert",
"sessionId": "optional-session-id"
}
Response (API-key mode):
{
"sessionId": "session-uuid",
"response": "I can help with that... (markdown + EQL JSON code block)",
"title": "BTC Breakout Alert",
"reasoning": null,
"planIds": []
}
The response message contains the AI's reply in Markdown. When it generates EQL, it will be
in a JSON code block — extract, validate via /queries/validate, then submit via /queries.
Prompting tips for Builder Chat:
- Include
titleanddescription(shown in notifications so recipients know what fired hours/days later) - Specify symbols, timeframe, trigger behavior (one-time — the default — vs recurring), delivery target. For recurring on the same condition, ask for the
repeatobject (cooldown+maxTriggers); for a fixed schedule, use acroncondition - For Signal triggers, give a factual match description (avoid vague phrasing like "bullish vibes")
- Append
"If anything is unsupported, return the closest supported query and list substitutions"to handle edge cases gracefully - Prefer
expiresInof24h–3dfor fresh signals - Persist
sessionIdand reuse it for follow-up prompts so the model keeps context across turns
High-impact prompt pack — drop these into POST /v2/auto/chat as the message field:
1) Complex TA breakout with direction filter:
Build an Auto query:
- title + description: short human-readable summary and 1-2 sentence thesis
- symbols: BTC, ETH, SOL
- timeframe: 5m
- trigger when price breaks previous 1h range high or low
- confirm direction with RSI(14): >55 for upside, <45 for downside
- actions: telegram alert + webhook to https://your-runner.example/auto/even
相关技能
通过 gmgn-cli 工具,查询 Solana、BSC、Base、Ethereum 上聪明钱、KOL 与个人关注钱包的实时买卖记录。
通过一个命令行工具完成多链加密货币交易、钱包管理与 AI 市场分析。
Crypto & DeFi market data for AI agents — spot prices, market data, DEX liquidity, DeFi protocol TVL, gas prices, Fear & Greed sentiment, trending coins, and...
通过 gmgn-cli 拉取任意钱包的结构化数据——持仓、盈亏、胜率、发币记录——覆盖 Solana、BSC、Base、Ethereum 四条链。
一条提示词搞定代币、DeFi、链上数据与组合策略的深度加密研究。