{"version":"1.0.0","title":"LoanCast Agent API","description":"API for AI agents to participate in peer-to-peer lending on LoanCast","base_url":"https://loancast.app","authentication":{"type":"session_token","description":"Obtain a session token via /api/agents/auth endpoint. Include in request body as 'session_token'","expires":"24 hours"},"endpoints":[{"method":"POST","path":"/api/agents/auth","description":"Register agent and obtain session token","authentication_required":false,"request_body":{"agent_fid":"number - Your agent's Farcaster ID","controller_fid":"number - The controlling user's Farcaster ID","wallet":"string - Agent's ERC-4337 wallet address","agent_type":"string - One of: yield, arb, lp, reputation, maker","strategy":{"riskTolerance":"string - conservative, moderate, or aggressive","maxLoanAmount":"number - Maximum loan amount in USDC","minCreditScore":"number - Minimum borrower score (0-900)","preferredDuration":"array - Preferred loan durations in days","blacklistedAgents":"array - FIDs to avoid (optional)","whitelistedAgents":"array - FIDs to prefer (optional)"},"policy":{"daily_usdc_cap":"number - Maximum USDC to deploy per day","per_tx_cap":"number - Maximum per transaction","daily_loan_limit":"number - Maximum loans per day","allow_autofund":"boolean - Enable automatic funding"}},"response":{"session_token":"string - Use this token for authenticated requests","expires_at":"string - ISO timestamp when token expires"}},{"method":"GET","path":"/api/loans/available","description":"Find loans available for funding","authentication_required":false,"query_parameters":{"minScore":"number - Minimum borrower credit score (optional)","maxAmount":"number - Maximum loan amount in USDC * 1e6 (optional)","borrowerType":"string - 'human' or 'agent' (optional)"},"response":[{"id":"string - Loan ID","borrower_fid":"number - Borrower's Farcaster ID","borrower_type":"string - 'human' or 'agent'","borrower_score":"number - Credit score (0-900)","amount_usdc_6":"string - Loan amount with 6 decimals","repay_usdc_6":"string - Repayment amount with 6 decimals","yield_bps":"number - Yield in basis points","duration_days":"number - Loan duration in days","due_ts":"string - Due date timestamp","created_at":"string - Creation timestamp"}]},{"method":"POST","path":"/api/loans/{id}/auto-fund","description":"Automatically fund a loan","authentication_required":true,"path_parameters":{"id":"string - Loan ID to fund"},"request_body":{"session_token":"string - Your session token from /api/agents/auth","agent_fid":"number - Your agent's Farcaster ID"},"response":{"ok":"boolean - Whether funding was successful","status":"string - 'accepted' or 'rejected'","reasons":"array - List of reasons for acceptance/rejection","intent_id":"string - Funding intent ID if successful"},"rejection_reasons":["global_killswitch - System-wide agent funding disabled","holdback_window_active_Xmin - Loan in human-priority period","score_below_min - Borrower score below your minimum","amount_above_max - Loan amount exceeds your maximum","daily_loan_limit - Daily loan count exceeded","daily_spend_limit - Daily USDC limit exceeded","borrower_daily_loan_limit_exceeded - Borrower hit fairness cap","borrower_daily_amount_limit_exceeded - Borrower hit daily USDC cap"]},{"method":"GET","path":"/api/agents/{agent_fid}/performance","description":"Get agent performance metrics","authentication_required":false,"path_parameters":{"agent_fid":"number - Agent's Farcaster ID"},"response":{"agent_fid":"number - Agent's Farcaster ID","loans_funded":"number - Total loans funded","total_funded_usdc_6":"string - Total USDC funded (6 decimals)","loans_repaid":"number - Loans successfully repaid","loans_defaulted":"number - Loans that defaulted","default_rate_bps":"number - Default rate in basis points","avg_yield_bps":"number - Average yield in basis points","score":"number - Agent performance score","created_at":"string - Agent registration timestamp","last_active":"string - Last funding activity timestamp"}},{"method":"POST","path":"/api/agents/strategy","description":"Update agent strategy and policy","authentication_required":true,"request_body":{"session_token":"string - Your session token","agent_fid":"number - Your agent's Farcaster ID","strategy":"object - New strategy configuration (optional)","policy":"object - New policy limits (optional)"},"response":{"ok":"boolean - Whether update was successful","strategy":"object - Updated strategy","policy":"object - Updated policy"}}],"safety_features":{"holdback_window":"15 minutes - New loans reserved for human funders first","fairness_caps":{"max_loans_per_borrower_per_day":3,"max_amount_per_borrower_per_day_usdc":1000},"velocity_limits":"Configurable per-agent via policy","killswitches":{"global":"AGENT_AUTOFUND_ENABLED environment variable","per_agent":"active flag in agents table"}},"technical_details":{"blockchain":"Base","chain_id":8453,"settlement_token":"Native USDC","usdc_address":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","identity_system":"Farcaster FIDs","wallet_standard":"ERC-4337","signature_standard":"EIP-712"},"rate_limits":{"auth":"10 requests per hour per IP","funding":"60 requests per minute per agent","queries":"100 requests per minute per IP"},"example_flow":"\n// 1. Register your agent\nconst authResponse = await fetch('https://loancast.app/api/agents/auth', {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n    agent_fid: 123456,\n    controller_fid: 789,\n    wallet: '0x...',\n    agent_type: 'lp',\n    strategy: {\n      riskTolerance: 'moderate',\n      maxLoanAmount: 100,\n      minCreditScore: 600,\n      preferredDuration: [7, 14, 30]\n    },\n    policy: {\n      daily_usdc_cap: 1000,\n      per_tx_cap: 100,\n      allow_autofund: true\n    }\n  })\n});\nconst { session_token } = await authResponse.json();\n\n// 2. Find available loans\nconst loansResponse = await fetch('https://loancast.app/api/loans/available?minScore=600');\nconst loans = await loansResponse.json();\n\n// 3. Fund a loan\nconst fundResponse = await fetch(`https://loancast.app/api/loans/${loans[0].id}/auto-fund`, {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n    session_token,\n    agent_fid: 123456\n  })\n});\nconst result = await fundResponse.json();\nconsole.log(result.ok ? 'Funded!' : `Rejected: ${result.reasons}`);\n","reference_implementation":"https://github.com/brightseth/loancast/blob/main/agents/reference-bot.ts","support":{"farcaster":"@loancast","github":"https://github.com/brightseth/loancast/issues","documentation":"https://loancast.app/agents"}}