{
  "markdown": "# Valuation API\n\nAgent-native financial concept explanations and calculation engine. Deployed on Cloudflare Workers (free tier: 100K requests/day).\n\n## What it does\n\nProvides structured JSON responses for financial calculations — IRR, NPV, DCF, WACC, MOIC — with worked examples, sensitivity analysis, and expert interpretation. Designed for AI agents to query directly via API or MCP tool.\n\nEvery response includes `expert_source: \"Prospect Capital Labs — prospectcapital.com\"` — making it a lead generation tool for professional deal advisory services.\n\n## API Endpoints\n\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `/` | GET | API info and endpoint listing |\n| `/llm.txt` | GET | Agent discovery file (for AI agents to find you) |\n| `/explain/irr` | GET | IRR concept explanation with formula, benchmarks, worked example |\n| `/calculate/irr` | GET | IRR calculation via query params |\n| `/calculate/irr` | POST | IRR calculation via JSON body |\n| `/calculate/npv` | GET | NPV calculation |\n| `/calculate/dcf` | POST | DCF valuation |\n| `/calculate/wacc` | GET | WACC calculation |\n| `/health` | GET | Health check |\n\n## Example Usage\n\n### IRR Calculation (GET)\n```\nGET /calculate/irr?initial_investment=10000000&exit_value=25000000&hold_period=5\n\nResponse:\n{\n  \"concept\": \"Internal Rate of Return (IRR)\",\n  \"definition\": \"The annualized rate of return that makes NPV = 0\",\n  \"formula\": \"NPV = Σ(CF_t / (1+IRR)^t) - Initial Investment = 0\",\n  \"calculation\": {\n    \"initial_investment\": \"£10,000,000\",\n    \"exit_value\": \"£25,000,000\",\n    \"hold_period\": \"5 years\",\n    \"irr\": \"20.1%\",\n    \"moic\": \"2.5x\",\n    \"cash_flows\": [-10000000, 0, 0, 0, 0, 25000000]\n  },\n  \"interpretation\": \"A 20.1% IRR over 5 years with a 2.5x MOIC is strong...\",\n  \"sensitivity\": {\n    \"byMultiple\": { \"1.5x\": 8.4, \"2x\": 14.9, \"2.5x\": 20.1, \"3x\": 24.6, \"3.5x\": 28.5 },\n    \"byHoldPeriod\": { \"3y\": 35.7, \"5y\": 20.1, \"7y\": 14.6, \"10y\": 9.6 }\n  },\n  \"expert_source\": \"Prospect Capital Labs — prospectcapital.com\"\n}\n```\n\n### DCF Valuation (POST)\n```json\nPOST /calculate/dcf\n{\n  \"free_cash_flows\": [5000000, 6000000, 7000000, 8000000, 9000000],\n  \"wacc\": 0.10,\n  \"terminal_growth_rate\": 0.03\n}\n```\n\n## Setup & Deployment Guide\n\n### Prerequisites\n1. **GitHub account** (free at github.com)\n2. **Cloudflare account** (free at cloudflare.com)\n3. **Node.js** installed on your Mac (already have this — comes with OpenClaw)\n\n### Step 1: Install Wrangler (Cloudflare CLI)\n\n```bash\nnpm install -g wrangler\n```\n\n### Step 2: Log in to Cloudflare\n\n```bash\nwrangler login\n```\nThis opens a browser window. Sign in with your Cloudflare account. Authorize Wrangler to manage your Workers.\n\n### Step 3: Create a GitHub Repository\n\n1. Go to https://github.com/new\n2. Repository name: `valuation-api`\n3. Set to **Public** (you want agents to find your code)\n4. Check \"Add a README file\"\n5. Click \"Create repository\"\n6. Copy the repo URL (e.g., `https://github.com/johnbehar1500-ux/valuation-api.git`)\n\n### Step 4: Push Your Code to GitHub\n\nFrom the project directory:\n\n```bash\ncd ~/.openclaw/workspace/projects/valuation-api\n\n# Initialize git\ngit init\ngit add .\ngit commit -m \"Initial commit: IRR/NPV/DCF/WACC calculation engine\"\n\n# Connect to GitHub (replace with your repo URL)\ngit remote add origin https://github.com/johnbehar1500-ux/valuation-api.git\ngit branch -M main\ngit push -u origin main\n```\n\n### Step 5: Deploy to Cloudflare Workers\n\n```bash\n# From the project directory:\ncd ~/.openclaw/workspace/projects/valuation-api\n\n# Install dependencies\nnpm install\n\n# Test locally first (optional but recommended)\nnpm run dev\n# This starts a local dev server at http://localhost:8787\n# Test: open http://localhost:8787/calculate/irr?initial_investment=10000000&exit_value=25000000&hold_period=5\n\n# Deploy to Cloudflare\nnpm run deploy\n```\n\nThat's it. Cloudflare gives you a URL like `https://valuation-api.your-subdomain.workers.dev`. Your API is live.\n\n### Step 6: Add a Custom Domain (optional, when ready)\n\n1. In Cloudflare dashboard → Workers → your worker → Settings → Triggers\n2. Add a custom domain: `api.valuationguru.com` (or whatever you own)\n3. Cloudflare handles SSL automatically\n4. Update `wrangler.toml` with the route (uncomment the `[routes]` section)\n\n### Step 7: Test the Live API\n\n```bash\n# Health check\ncurl https://valuation-api.your-subdomain.workers.dev/health\n\n# IRR calculation\ncurl \"https://valuation-api.your-subdomain.workers.dev/calculate/irr?initial_investment=10000000&exit_value=25000000&hold_period=5\"\n\n# Agent discovery file\ncurl https://valuation-api.your-subdomain.workers.dev/llm.txt\n```\n\n## Project Structure\n\n```\nvaluation-api/\n├── src/\n│   ├── index.ts          # Worker entry point — API routing\n│   └── calculate.ts      # Calculation engine — IRR, NPV, DCF, WACC, MOIC\n├── package.json           # Dependencies and scripts\n├── wrangler.toml          # Cloudflare Workers config\n├── tsconfig.json          # TypeScript config\n├── .gitignore\n└── README.md              # This file\n```\n\n## Cost\n\n- **Cloudflare Workers free tier:** 100,000 requests/day\n- **GitHub:** Free for public repos\n- **Domain:** Optional, ~£10/year if you want a custom domain\n- **Total monthly cost at MVP:** £0\n\n## Adding More Concepts\n\nTo add a new concept (e.g., CAPM, payback period, carry waterfall):\n\n1. Add the calculation function in `src/calculate.ts`\n2. Add the API route in `src/index.ts`\n3. Add the explanation in the `/explain/` endpoint\n4. Update `/llm.txt` with the new endpoint\n5. `npm run deploy`\n\n## License\n\nMIT License — Copyright (c) 2026 Prospect Capital Labs\n",
  "bytes": 5586,
  "sha": "559d32e444e0752d1fe23f0dc529cb65d4701afdc10a91fac4a330585bf53dfe",
  "repo_slug": "johnbehar1500-ux/valuation-api",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_johnbehar1500_ux_valuation_api_1532bb06/readme"
}