跳到正文
Skillpedia
API 与服务器(后端)7.0k · #13633

integrating-jupiter

它能做什么

这项技能是基于 Solana 上 Jupiter API 进行开发的参考资料,涵盖兑换、借贷、永续合约、代币价格、投资组合等内容。它帮助选择合适的端点、遵循正确的步骤并处理错误,适合在应用中加入 Jupiter 的开发者。

适用场景

  • ✓当你想在应用中使用 Jupiter 添加代币兑换功能的时候。
  • ✓当你需要在借贷、订单或价格的 Jupiter 端点之间做选择时。
  • ✓当 Jupiter API 调用失败,并且你想获得调试帮助的时候。

技能链接

https://github.com/internet-court/internet-court-skill/blob/main/vendored/jupiter/integrating-jupiter/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/internet-court/internet-court-skill/blob/main/vendored/jupiter/integrating-jupiter/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我想使用 Jupiter 的 API 为我的 Solana 应用添加代币兑换功能。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会为你的任务选择合适的 Jupiter API,然后遵循集成步骤。REST 端点需要从 Jupiter 开发者门户获取 API 密钥。该技能还涵盖生产环境加固,例如妥善处理错误。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Jupiter API Integration

Single skill for all Jupiter APIs, optimized for fast routing and deterministic execution.

Base URL: https://api.jup.ag Auth: x-api-key from developers.jup.ag (required for Jupiter REST endpoints)

Use/Do Not Use

Use when:

  • The task requires choosing or calling Jupiter endpoints.
  • The task involves swap, lending, perps, orders, pricing, portfolio, send, studio, lock, or routing.
  • The user needs debugging help for Jupiter API calls.

Do not use when:

  • The task is generic Solana setup with no Jupiter API usage.
  • The task is UI-only with no API behavior decisions.
  • The agent context is not DeFi/crypto (generic triggers like buy, sell, trade assume a DeFi domain).

Triggers: swap, quote, gasless, best route, buy, sell, trade, convert, token exchange, jupiter api, jup.ag, ultra, metis, ultra swap, ultra api, ultra-api.jup.ag, lend, borrow, earn, yield, apy, deposit, liquidation, perps, leverage, long, short, position, futures, margin trading, limit order, trigger, price condition, dca, recurring, scheduled swaps, token metadata, token search, verification, shield, price, valuation, price feed, portfolio, positions, holdings, prediction markets, market odds, event market, invite transfer, send, clawback, create token, studio, claim fee, vesting, distribution lock, unlock schedule, dex integration, rfq integration, routing engine, status page, health check, service health, accumulate, auto-buy

Developer Quickstart

import { Connection, Keypair, VersionedTransaction } from '@solana/web3.js';

const API_KEY = process.env.JUPITER_API_KEY!;  // from developers.jup.ag
if (!API_KEY) throw new Error('Missing JUPITER_API_KEY');
const BASE = 'https://api.jup.ag';
const headers = { 'x-api-key': API_KEY };

async function jupiterFetch<T>(path: string, init?: RequestInit): Promise<T> {
  const res = await fetch(`${BASE}${path}`, {
    ...init,
    headers: { ...headers, ...init?.headers },
  });
  if (res.status === 429) throw { code: 'RATE_LIMITED', retryAfter: Number(res.headers.get('Retry-After')) || 10 };
  if (!res.ok) {
    const raw = await res.text();
    let body: any = { message: raw || `HTTP_${res.status}` };
    try {
      body = raw ? JSON.parse(raw) : body;
    } catch {
      // keep text fallback body
    }
    throw { status: res.status, ...body };
  }
  return res.json();
}

// Sign and send any Jupiter transaction
async function signAndSend(
  txBase64: string,
  wallet: Keypair,
  connection: Connection,
  additionalSigners: Keypair[] = []
): Promise<string> {
  const tx = VersionedTransaction.deserialize(Buffer.from(txBase64, 'base64'));
  tx.sign([wallet, ...additionalSigners]);
  const sig = await connection.sendRawTransaction(tx.serialize(), {
    maxRetries: 0,
    skipPreflight: true,
  });
  return sig;
}

Token Amounts & Decimals

Every Jupiter amount field is in the token's smallest unit (raw integer) — never a human/UI value.

  • Common decimals: SOL & wSOL = 9, USDC & USDT = 6. Canonical mints: SOL So11111111111111111111111111111111111111112, USDC EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v.
  • Convert human → raw: raw = Math.round(human * 10 ** decimals). Examples: 1 SOL → 1_000_000_000, 100 USDC → 100_000_000. slippageBps is basis points: 0.5% = 50, 1% = 100.
  • Read decimals per-mint on-chain with getMint(connection, mintPubkey) from @solana/spl-token — never hardcode (decimals vary by token), and do not call the Price API just to discover decimals.

Intent Router (first step)

User intent API family First action
Swap/quote Swap GET /swap/v2/order -> sign -> POST /swap/v2/execute
Lend/borrow/yield Lend POST /lend/v1/earn/deposit or /withdraw
Leverage/perps Perps On-chain via Anchor IDL (no REST API yet)
Limit orders Trigger JWT auth -> POST /trigger/v2/orders/price
DCA/recurring buys Recurring POST /recurring/v1/createOrder -> sign -> POST /recurring/v1/execute
Token search Tokens GET /tokens/v2/search?query={mint}
Token verification/metadata update Use jupiter-vrfd skill Defer — not handled by this skill
Price lookup Price
常见问题

Jupiter 需要 API 密钥吗?

需要。REST 端点要求 x-api-key 请求头,你可以从 Jupiter 开发者门户获取。

该技能涵盖哪些 Jupiter 产品?

兑换、借贷、永续合约、触发订单、定期订单、代币、价格、投资组合、预测市场、发送、studio、lock 以及路由。

它对普通的 Solana 设置有帮助吗?

没有。它用于使用 Jupiter 的 API,而不是通用的 Solana 设置。

详情

作者的原始描述

Comprehensive guidance for integrating Jupiter APIs (Swap, Lend, Perps, Trigger, Recurring, Tokens, Price, Portfolio, Prediction Markets, Send, Studio, Lock, Routing). Use for endpoint selection, integration flows, error handling, and production hardening.

repo: internet-court/internet-court-skill

热度

GitHub 星标
7.0k
排名
#13633
许可证
—
更新时间
2026/10/26

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能