Loading...
Loading...
Wire Alchemy into application code (server, backend, dApp, script) using a standard API key. Preferred app-integration path for normal server/backend usage. Covers EVM JSON-RPC, WebSocket subscriptions, Simulation, Webhooks/Notify, Solana RPC, Solana DAS, Solana Yellowstone gRPC, Sui gRPC, Wallets/Account Kit, Account Abstraction, and operational topics. Requires `$ALCHEMY_API_KEY`. For app code without an API key (autonomous agent paying per-request, or explicit x402/MPP), use `alchemy-agentic-gateway` instead.
npx skill4agent add allium-labs/skills alchemy-apireferences/alchemy-api| Situation | Use this skill instead |
|---|---|
Live agent work in this session (queries, admin, on-machine automation) and | |
| Live agent work in this session and only MCP is wired into the client (no CLI) | |
| Live agent work and neither is available | install |
| Application code without an API key — autonomous agent paying per-request, or user explicitly wants x402/MPP | |
alchemy-clialchemy-mcpalchemy-clialchemy-mcp$ALCHEMY_API_KEYecho $ALCHEMY_API_KEY$ALCHEMY_API_KEY@alchemy/cliagentic-gateway.../v2/demo@alchemy/clicommand -v alchemy.envSecurity: NEVER echo, print, or otherwise surface the extracted API key value in conversation output. Refer to it only asafter exporting. Treat it the same as a password.$ALCHEMY_API_KEY
# 1. Try to read a cached key from the CLI config (read-only, safe to run non-interactively).
KEY="$(alchemy --no-interactive --json --reveal config get api-key 2>/dev/null | jq -r .value)"
# 2. If empty/null (no key cached yet), run the interactive flow.
# Note: auth login opens a browser and apps select shows a picker, so do NOT pass
# --no-interactive here. If you already know the app id, pass it explicitly to skip
# the picker: `alchemy --no-interactive --json apps select <id>`.
if [ -z "$KEY" ] || [ "$KEY" = "null" ]; then
alchemy auth login # opens browser; derives auth credentials
alchemy --json apps select # interactive picker (omit --no-interactive so it can render)
KEY="$(alchemy --no-interactive --json --reveal config get api-key | jq -r .value)"
fi
# 3. Persist to the project's .env (standard practice for app code so the key
# survives terminal restarts and is loaded by dotenv / framework env loaders).
# Use .env.local instead if your framework expects that (e.g. Next.js).
ENV_FILE=".env" # or ".env.local" depending on the project convention
touch "$ENV_FILE"
if grep -q '^ALCHEMY_API_KEY=' "$ENV_FILE"; then
# Replace existing line in-place (portable across BSD/GNU sed)
sed -i.bak "s|^ALCHEMY_API_KEY=.*|ALCHEMY_API_KEY=$KEY|" "$ENV_FILE" && rm "$ENV_FILE.bak"
else
echo "ALCHEMY_API_KEY=$KEY" >> "$ENV_FILE"
fi
# 4. Make sure the env file is git-ignored.
grep -qxF "$ENV_FILE" .gitignore 2>/dev/null || echo "$ENV_FILE" >> .gitignore
# 5. Also export to the current shell so the agent can immediately call the API.
export ALCHEMY_API_KEY="$KEY"Why we persist to: without it, the key is only set for the current shell session and disappears when the terminal tab closes. App code typically loads.envvia.env(Node),dotenv(Python),python-dotenv, or framework-native loaders (Next.js, Vite, Bun, Deno, Rails, etc.), so writing todirenvis the canonical way to make the key durable for both.envand the deployed app's local copy.npm run dev
Why this whole flow works: the CLI is a runtime executor (skill). When the user has it installed, you can use it to provision the credential that this app-code skill needs, write it to a place the application will load, then hand off to the rest of thealchemy-cliflow. After step 5, continue with the Base URLs + auth and Quickstart below.alchemy-api
Gotcha: ifsucceeded butauth loginstill returns "not found," the CLI'sconfig get api-keymay have falsely reportedsetup statuswith only ancomplete: true. Re-runauth_token(or pass an explicitalchemy --json apps selectwith<id>) to bind a default app, then retry. See the--no-interactiveskill for the same gotcha documented under Preflight.alchemy-cli
| Product | Base URL | Auth | Notes |
|---|---|---|---|
| Ethereum RPC (HTTPS) | | API key in URL | Standard EVM reads and writes. |
| Ethereum RPC (WSS) | | API key in URL | Subscriptions and realtime. |
| Base RPC (HTTPS) | | API key in URL | EVM L2. |
| Base RPC (WSS) | | API key in URL | Subscriptions and realtime. |
| Arbitrum RPC (HTTPS) | | API key in URL | EVM L2. |
| Arbitrum RPC (WSS) | | API key in URL | Subscriptions and realtime. |
| BNB RPC (HTTPS) | | API key in URL | EVM L1. |
| BNB RPC (WSS) | | API key in URL | Subscriptions and realtime. |
| Solana RPC (HTTPS) | | API key in URL | Solana JSON-RPC. |
| Solana Yellowstone gRPC | | | gRPC streaming (Yellowstone). |
| Sui gRPC | | | Sui gRPC API (objects, txs, balances, streaming). |
| Notify API | | | Generate token in dashboard. |
| You need | Use this | Skill / file |
|---|---|---|
| EVM read/write | JSON-RPC | |
| Realtime events | | |
| Simulate tx | | |
| Create webhook | | |
| Solana DAS | | |
| Sui objects/txs | | |
| Sui balances | | |
| Sui checkpoints stream | | |
No API key? Use theskill instead. Replace API-key URLs withagentic-gatewayand addhttps://x402.alchemy.com/eth-mainnet/v2(orAuthorization: SIWE <token>for a Solana wallet). See theSIWS <token>skill for setup.agentic-gateway
curl -s https://eth-mainnet.g.alchemy.com/v2/$ALCHEMY_API_KEY \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params":[]}'curl -s -X POST "https://dashboard.alchemy.com/api/create-webhook" \
-H "Content-Type: application/json" \
-H "X-Alchemy-Token: $ALCHEMY_NOTIFY_AUTH_TOKEN" \
-d '{"network":"ETH_MAINNET","webhook_type":"ADDRESS_ACTIVITY","webhook_url":"https://example.com/webhook","addresses":["0x00000000219ab540356cbb839cbe05303d7705fa"]}'import crypto from "crypto";
export function verify(rawBody: string, signature: string, secret: string) {
const hmac = crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
return crypto.timingSafeEqual(Buffer.from(hmac), Buffer.from(signature));
}eth-mainnetETH_MAINNET| Token | Chain | Address |
|---|---|---|
| ETH | ethereum | |
| WETH | ethereum | |
| USDC | ethereum | |
| USDC | base | |
429errorpageKeyreferences/skill-map.md| The user wants to... | Hand off to |
|---|---|
| Run a one-off live query, admin command, or on-machine automation in this session (CLI installed) | |
| Run a one-off live query in this session (only MCP wired in) | |
| Build app code without an API key (autonomous agent, or explicit x402/MPP) | |
$ALCHEMY_API_KEYecho $ALCHEMY_API_KEYreferences/operational-allowlists.mdreferences/operational-rate-limits-and-compute-units.mdeth-mainnetbase-mainnetETH_MAINNETBASE_MAINNETreferences/operational-supported-networks.mderrorresponse.error