Skip to main content
bankr-dev-client-patterns This skill should be used when the user asks to "implement Bankr client", "write bankr-client.ts", "create API client for Bankr", "common files for Bankr project", "package.json for Bankr", "tsconfig for Bankr", "Bankr TypeScript patterns", "Bankr response types", or needs the reusable client code and common project files for Bankr API integrations.
跳到安装 Skills Marketplace 发现并探索由社区构建的 Agent Skills
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/BankrBot/claude-plugins --skill bankr-dev-client-patterns命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
下载 Zip 下载中... 同仓库更多 Skills This skill should be used when building the async job workflow, implementing polling loops, handling job status transitions, processing rich data, managing conversation threads, or understanding the full submit-poll-complete lifecycle of the Bankr Agent API.
bankr-dev-safety-access-control This skill should be used when building secure Bankr integrations, implementing API key management, configuring access controls, setting up dedicated agent wallets, or handling rate limits and security best practices in Bankr API projects.
bankr-dev-sign-submit-api This skill should be used when building apps that need to sign messages, sign typed data (EIP-712), sign transactions, or submit raw transactions via the Bankr API. Covers the synchronous /agent/sign and /agent/submit endpoints with TypeScript patterns.
name Bankr Dev - Client Patterns description This skill should be used when the user asks to "implement Bankr client", "write bankr-client.ts", "create API client for Bankr", "common files for Bankr project", "package.json for Bankr", "tsconfig for Bankr", "Bankr TypeScript patterns", "Bankr response types", or needs the reusable client code and common project files for Bankr API integrations. version 1.0.0
Bankr Client Patterns
Reusable client code and common files for Bankr API projects.
bankr-client.ts
The core API client module for all Bankr projects:
import "dotenv/config" ;
const API_URL = process.env .BANKR_API_URL || "https://api.bankr.bot" ;
const API_KEY = process.env .BANKR_API_KEY ;
export type JobStatus = "pending" | "processing" | "completed" | "failed" | ;
{
: ;
: ;
: ;
: ;
?: ;
?: [];
?: [];
?: [];
?: ;
: ;
?: ;
?: ;
?: ;
?: ;
?: ;
}
{
: ;
: ;
}
=
|
|
|
|
|
|
|
|
|
|
|
|
| ;
{
: {
: ;
: ;
: ;
: ;
: ;
: ;
: ;
: ;
};
: {
: ;
: ;
: ;
: ;
: ;
: ;
};
}
{
: ;
: & {
?: ;
?: { : ; : };
?: ;
};
}
{
: ;
: ;
}
{
: ;
: ;
}
{
: ;
: ;
}
{
: ;
: ;
}
{
: ;
: ;
}
{
: ;
: ;
}
{
: ;
: ;
}
{
: ;
: ;
}
{
: ;
: ;
}
{
: ;
: {
: ;
: ;
: ;
: ;
?: ;
};
}
{
: ;
: {
: ;
: ;
: ;
: ;
: ;
};
}
{
: ;
: {
: ;
: ;
: ;
: ;
?: ;
};
}
= | ;
{
: ;
: ;
: ;
}
{
: ;
: ;
}
( ): <{ : }> {
(! ) {
( );
}
response = ( , {
: ,
: {
: ,
: ,
},
: . ({ prompt }),
});
(!response. ) {
text = response. ();
( );
}
data = response. ();
(!data. ) {
(data. || );
}
{ : data. };
}
( ): < > {
(! ) {
( );
}
response = ( , {
: { : },
});
(!response. ) {
text = response. ();
( );
}
response. ();
}
( ): < > {
(! ) {
( );
}
response = ( , {
: ,
: {
: ,
: ,
},
});
(!response. ) {
text = response. ();
( );
}
response. ();
}
( ): < > {
pollInterval = options?. || ;
maxAttempts = options?. || ;
lastUpdateCount = ;
( attempt = ; attempt < maxAttempts; attempt++) {
status = (jobId);
(onProgress && status. ) {
( i = lastUpdateCount; i < status. . ; i++) {
(status. [i]. );
}
lastUpdateCount = status. . ;
}
([ , , ]. (status. )) {
status;
}
( (resolve, pollInterval));
}
( );
}
( ): < > {
{ jobId } = (prompt);
onProgress?.( );
(jobId, onProgress);
}
"cancelled"
export
interface
JobStatusResponse
success
boolean
jobId
string
status
JobStatus
prompt
string
response
string
transactions
Transaction
richData
RichData
statusUpdates
StatusUpdate
error
string
createdAt
string
startedAt
string
completedAt
string
cancelledAt
string
processingTime
number
cancellable
boolean
export
interface
StatusUpdate
message
string
timestamp
string
export
type
Transaction
SwapTransaction
ApprovalTransaction
TransferErc20Transaction
TransferEthTransaction
ConvertEthToWethTransaction
ConvertWethToEthTransaction
TransferNftTransaction
MintManifoldNftTransaction
MintSeaDropNftTransaction
BuyNftTransaction
AvantisTradeTransaction
SwapCrossChainTransaction
ManageBankrStakingTransaction
interface
BaseTransactionMetadata
__ORIGINAL_TX_DATA__
chain
string
humanReadableMessage
string
inputTokenAddress
string
inputTokenAmount
string
inputTokenTicker
string
outputTokenAddress
string
outputTokenTicker
string
receiver
string
transaction
chainId
number
to
string
data
string
gas
string
gasPrice
string
value
string
export
interface
SwapTransaction
type
"swap"
metadata
BaseTransactionMetadata
approvalRequired
boolean
approvalTx
to
string
data
string
permit2
object
export
interface
ApprovalTransaction
type
"approval"
metadata
BaseTransactionMetadata
export
interface
TransferErc20Transaction
type
"transfer_erc20"
metadata
BaseTransactionMetadata
export
interface
TransferEthTransaction
type
"transfer_eth"
metadata
BaseTransactionMetadata
export
interface
ConvertEthToWethTransaction
type
"convert_eth_to_weth"
metadata
BaseTransactionMetadata
export
interface
ConvertWethToEthTransaction
type
"convert_weth_to_eth"
metadata
BaseTransactionMetadata
export
interface
TransferNftTransaction
type
"transfer_nft"
metadata
BaseTransactionMetadata
export
interface
MintManifoldNftTransaction
type
"mint_manifold_nft"
metadata
BaseTransactionMetadata
export
interface
MintSeaDropNftTransaction
type
"mint_seadrop_nft"
metadata
BaseTransactionMetadata
export
interface
BuyNftTransaction
type
"buy_nft"
metadata
BaseTransactionMetadata
export
interface
AvantisTradeTransaction
type
"avantisTrade"
metadata
chainId
number
description
string
to
string
data
string
value
string
export
interface
SwapCrossChainTransaction
type
"swapCrossChain"
metadata
chainId
number
description
string
to
string
data
string
value
string
export
interface
ManageBankrStakingTransaction
type
"manage_bankr_staking"
metadata
chainId
number
description
string
to
string
data
string
value
string
export
type
RichData
SocialCard
Chart
export
interface
SocialCard
type
"social-card"
variant
"analysis"
text
string
export
interface
Chart
type
"chart"
url
string
export
async
function
submitPrompt
prompt : string
Promise
jobId
string
if
API_KEY
throw
new
Error
"BANKR_API_KEY not set. Get one at https://bankr.bot/api"
const
await
fetch
`${API_URL} /agent/prompt`
method
"POST"
headers
"x-api-key"
API_KEY
"Content-Type"
"application/json"
body
JSON
stringify
if
ok
const
await
text
throw
new
Error
`API error ${response.status} : ${text} `
const
await
json
if
success
throw
new
Error
error
"Failed to submit prompt"
return
jobId
jobId
export
async
function
getJobStatus
jobId : string
Promise
JobStatusResponse
if
API_KEY
throw
new
Error
"BANKR_API_KEY not set"
const
await
fetch
`${API_URL} /agent/job/${jobId} `
headers
"x-api-key"
API_KEY
if
ok
const
await
text
throw
new
Error
`API error ${response.status} : ${text} `
return
json
export
async
function
cancelJob
jobId : string
Promise
JobStatusResponse
if
API_KEY
throw
new
Error
"BANKR_API_KEY not set"
const
await
fetch
`${API_URL} /agent/job/${jobId} /cancel`
method
"POST"
headers
"x-api-key"
API_KEY
"Content-Type"
"application/json"
if
ok
const
await
text
throw
new
Error
`API error ${response.status} : ${text} `
return
json
export
async
function
waitForCompletion
jobId : string ,
onProgress ?: (message: string ) => void ,
options ?: { pollInterval?: number ; maxAttempts?: number }
Promise
JobStatusResponse
const
pollInterval
2000
const
maxAttempts
150
let
0
for
let
0
const
await
getJobStatus
if
statusUpdates
for
let
statusUpdates
length
onProgress
statusUpdates
message
statusUpdates
length
if
"completed"
"failed"
"cancelled"
includes
status
return
await
new
Promise
(resolve ) =>
setTimeout
throw
new
Error
"Job timed out after maximum attempts"
export
async
function
execute
prompt : string ,
onProgress ?: (message: string ) => void
Promise
JobStatusResponse
const
await
submitPrompt
`Job submitted: ${jobId} `
return
waitForCompletion
Common Files
package.json Base package.json for all Bankr projects:
{
"name" : "{project-name}" ,
"version" : "0.1.0" ,
"description" : "{description}" ,
"type" : "module" ,
"main" : "dist/index.js" ,
"scripts" : {
"build" : "tsc" ,
"start" : "node dist/index.js" ,
"dev" : "tsx src/index.ts"
} ,
"dependencies" : {
"dotenv" : "^16.3.1"
} ,
"devDependencies" : {
"@types/node" : "^20.10.0" ,
"tsx" : "^4.7.0" ,
"typescript" : "^5.3.0"
}
}
Framework-Specific Dependencies Add based on project template:
"dependencies" : {
"express" : "^4.18.0"
} ,
"devDependencies" : {
"@types/express" : "^4.17.21"
}
"dependencies" : {
"fastify" : "^4.25.0"
}
"dependencies" : {
"commander" : "^12.0.0"
}
tsconfig.json TypeScript configuration:
{
"compilerOptions" : {
"target" : "ES2022" ,
"module" : "NodeNext" ,
"moduleResolution" : "NodeNext" ,
"outDir" : "./dist" ,
"rootDir" : "./src" ,
"strict" : true ,
"esModuleInterop" : true ,
"skipLibCheck" : true ,
"forceConsistentCasingInFileNames" : true ,
"declaration" : true
} ,
"include" : [ "src/**/*" ] ,
"exclude" : [ "node_modules" , "dist" ]
}
.env.example Environment variables template:
BANKR_API_KEY=bk_your_api_key_here
BANKR_API_URL=https://api.bankr.bot
BANKR_WALLET_ADDRESS=0x...
.gitignore Standard ignore patterns:
# Dependencies
node_modules/
# Build output
dist/
# Environment
.env
.env.local
.env.*.local
# Logs
*.log
npm-debug.log*
# IDE
.idea/
.vscode/
*.swp
*.swo
# OS
.DS_Store
Thumbs.db
# Testing
coverage/
Usage Patterns
Basic Usage import { execute } from "./bankr-client" ;
const result = await execute ("What is the price of ETH?" , (msg ) => {
console .log ("Progress:" , msg);
});
console .log (result.response );
With Error Handling import { execute } from "./bankr-client" ;
try {
const result = await execute ("Buy $50 of ETH on Base" );
if (result.status === "completed" ) {
console .log ("Success:" , result.response );
if (result.transactions ) {
for (const tx of result.transactions ) {
console .log (`${tx.type } :` , tx.metadata .__ORIGINAL_TX_DATA__ ?.humanReadableMessage );
}
}
} else if (result.status === "failed" ) {
console .error ("Failed:" , result.error );
}
} catch (error) {
console .error ("Error:" , error.message );
}
Manual Control import { submitPrompt, waitForCompletion, cancelJob } from "./bankr-client" ;
const { jobId } = await submitPrompt ("Analyze ETH market" );
const timeout = setTimeout (() => {
cancelJob (jobId);
}, 120000 );
const result = await waitForCompletion (jobId, console .log , {
pollInterval : 2000 ,
maxAttempts : 60 ,
});
clearTimeout (timeout);
API Reference Consult the bankr-api-basics skill for:
Complete endpoint documentation
Authentication details
Response field descriptions
Error codes and handling