> ## Documentation Index
> Fetch the complete documentation index at: https://docs.afkcrypto.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 快速开始

> 你的第一条 AFK Crypto API 请求

## 4 步完成入门

创建账户、开启自动化、创建 API Key，并发起你的第一条请求。

### 步骤 1：登录

<AccordionGroup>
  <Accordion icon="user" title="登录你的账户">
    访问 <a href="https://app.afkcrypto.com">app.afkcrypto.com</a> 登录。
  </Accordion>
</AccordionGroup>

### 步骤 2：开启自动化（钱包）

<AccordionGroup>
  <Accordion icon="toggle-on" title="允许 AFK 代你签名（非托管）">
    在 <a href="https://app.afkcrypto.com/wallets">Wallets</a> 页面，为你的地址打开 Automation。AFK 将基于会话的非托管签名为自动化流程签署交易。你可随时撤销。
  </Accordion>
</AccordionGroup>

### 步骤 3：创建 API Key（钱包自动化）

<AccordionGroup>
  <Accordion icon="key" title="创建 API Key">
    在控制台 <a href="https://app.afkcrypto.com/api-keys">API Keys</a> 页面创建钱包自动化的 API Key。

    * 请求头：`x-api-key: afk_<prefix>_<random>`
    * 请妥善保管；若泄露请立即轮换

    详见 <a href="/api-reference/authentication/">身份验证</a>。
  </Accordion>
</AccordionGroup>

### 步骤 4：发起 API 请求

<AccordionGroup>
  <Accordion icon="list" title="列出钱包">
    将 API Key 设置到环境变量方便复用：

    ```bash theme={null}
    export AFK_API_KEY="afk_abcd_xxx"
    ```

    ```bash theme={null}
    curl -s -H "x-api-key: $AFK_API_KEY" \
      "https://api.afkcrypto.com/v1/wallets?chain=ethereum"
    ```

    ```json theme={null}
    {
      "wallets": [
        {
          "address": "0xabc...",
          "chainType": "ethereum",
          "isDefault": true,
          "automationEnabled": true,
          "providerType": "embedded",
          "clientType": "privy"
        }
      ]
    }
    ```
  </Accordion>

  <Accordion icon="paper-plane" title="发送资产（幂等）">
    在所有写入端点提供 `Idempotency-Key: <uuid>`。

    ```bash theme={null}
    curl -s -X POST https://api.afkcrypto.com/v1/send \
      -H "x-api-key: $AFK_API_KEY" -H "Idempotency-Key: $(uuidgen)" \
      -H "Content-Type: application/json" \
      -d '{
        "chain":"base-sepolia",
        "asset":"erc20",
        "token":"0xToken",
        "to":"0xRecipient",
        "amount":"1000000000000000000"
      }'
    ```

    ```json theme={null}
    { "id": "tx_...", "status": "SUBMITTED", "hash": "0x...", "explorerUrl": "https://basescan.org/tx/0x...", "chainName": "Base" }
    ```
  </Accordion>

  <Accordion icon="bolt" title="与合约交互（EVM）">
    ```bash theme={null}
    curl -s -X POST https://api.afkcrypto.com/v1/contracts/send \
      -H "x-api-key: $AFK_API_KEY" -H "Idempotency-Key: $(uuidgen)" \
      -H "Content-Type: application/json" \
      -d '{
        "chain":"base-sepolia",
        "to":"0xContract",
        "data":"0xabcdef...",
        "value":"0"
      }'
    ```
  </Accordion>

  <Accordion icon="circle-nodes" title="发送 SPL 代币（Solana）">
    ```bash theme={null}
    curl -s -X POST https://api.afkcrypto.com/v1/send \
      -H "x-api-key: $AFK_API_KEY" -H "Idempotency-Key: $(uuidgen)" \
      -H "Content-Type: application/json" \
      -d '{
        "chain":"solana-devnet",
        "asset":"spl",
        "token":"MintAddress",
        "to":"RecipientOwnerAddress",
        "amount":"1000000"
      }'
    ```
  </Accordion>

  <Accordion icon="receipt" title="查询交易">
    ```bash theme={null}
    curl -s -H "x-api-key: $AFK_API_KEY" \
      "https://api.afkcrypto.com/v1/tx/tx_cuid_here"
    ```

    ```json theme={null}
    {
      "id":"tx_cuid_here",
      "status":"PENDING",
      "hash": null,
      "explorerUrl": null,
      "chainName":"Base",
      "chainType":"ethereum",
      "chainId":8453,
      "to":"0xrecipient...",
      "value":"1000000000000000",
      "error": null,
      "createdAt":"2025-08-25T08:00:00.000Z",
      "updatedAt":"2025-08-25T08:00:00.000Z"
    }
    ```
  </Accordion>
</AccordionGroup>

## 下一步

继续浏览核心端点：

<CardGroup cols={2}>
  <Card title="发送资产" icon="paper-plane" href="/api-reference/endpoint/send/">
    转账原生资产与代币资产。
  </Card>

  <Card title="授权代币" icon="key" href="/api-reference/endpoint/token-approve/">
    设置 ERC20 授权额度。
  </Card>

  <Card title="交易/兑换" icon="right-left" href="/api-reference/endpoint/trade-quote/">
    请求报价并执行兑换。
  </Card>

  <Card title="API 文档" icon="code" href="/api-reference/introduction/">
    浏览端点与约定。
  </Card>
</CardGroup>

<Note>
  **需要帮助？** 发送邮件至 <a href="mailto:hello@afkcrypto.com">[hello@afkcrypto.com](mailto:hello@afkcrypto.com)</a>，或在 <a href="https://twitter.com/afkcryptoai">Twitter</a> 联系我们。
</Note>
