Square Mile Labs API Documentation

Authentication

All API endpoints require JWT authentication. To get started:

  1. Register for a new account
  2. Login to receive your JWT token

Add Numbers Endpoint

URL: /add

Method: POST

Headers:

Authorisation: Bearer YOUR_JWT_TOKEN

Request Body:

{
    "num1": 10,
    "num2": 20
}

Response:

{
    "result": 30
}

Simple Interest Calculation Endpoint

URL: /finance/simple-interest

Method: POST

Headers:

Authorisation: Bearer YOUR_JWT_TOKEN

Request Body:

{
            "principal": 1000,
            "rate": 5,
            "time": 2
        }

Response:

{
            "simple_interest": 100
        }

Compound Interest Calculation Endpoint

URL: /finance/compound-interest

Method: POST

Headers:

Authorisation: Bearer YOUR_JWT_TOKEN

Request Body:

{
            "principal": 1000,
            "rate": 5,
            "time": 2,
            "n": 1
        }

Response:

{
            "compound_interest": 1102.5
        }

Net Present Value (NPV) Calculation Endpoint

URL: /finance/npv

Method: POST

Headers:

Authorisation: Bearer YOUR_JWT_TOKEN

Request Body:

{
            "cash_flows": [-1000, 300, 400, 500],
            "discount_rate": 0.1
        }

Response:

{
            "npv": 49.59
        }

Loan EMI Calculation Endpoint

URL: /finance/emi

Method: POST

Headers:

Authorisation: Bearer YOUR_JWT_TOKEN

Request Body:

{
            "principal": 10000,
            "annual_interest_rate": 10,
            "loan_term_years": 5
        }

Response:

{
            "emi": 212.47
        }

Future Value of an Investment Endpoint

URL: /finance/future-value

Method: POST

Headers:

Authorisation: Bearer YOUR_JWT_TOKEN

Request Body:

{
            "principal": 1000,
            "rate": 5,
            "time": 10
        }

Response:

{
            "future_value": 1628.89
        }

Currency Conversion Endpoint

URL: /finance/currency-conversion

Method: POST

Headers:

Authorisation: Bearer YOUR_JWT_TOKEN

Request Body:

{
            "amount": 100,
            "from_currency": "USD",
            "to_currency": "EUR",
            "exchange_rate": 0.85
        }

Response:

{
            "converted_amount": 85
        }

Profit and Loss Calculation Endpoint

URL: /finance/profit-loss

Method: POST

Headers:

Authorization: Bearer YOUR_JWT_TOKEN

Request Body:

{
            "cost_price": 100,
            "selling_price": 120
        }

Response:

{
            "profit": 20,
            "loss": 0
        }

Email Headers Analysis Endpoint

URL: /analyze-headers

Method: POST

Headers:

Authorisation: Bearer YOUR_JWT_TOKEN

Request Body:

{
    "headers": "Received: from example.com...[full email headers text]"
}

Response:

{
    "fraud_detected": true|false,
    "analysis": {
        "spf_passed": true|false,
        "dkim_passed": true|false,
        "dmarc_passed": true|false,
        "suspicious_ips": ["ip1", "ip2"],
        "suspicious_x_headers": ["header1", "header2"]
    }
}
Endpoints: POST /auth/register: Register a new user (bank employee or system). POST /auth/login: Log in and receive a JWT token. POST /auth/refresh: Refresh an expired JWT token. POST /auth/logout: Invalidate the current JWT token. GET /auth/user: Get details of the authenticated user. 2. Core Financial Calculations This section provides essential financial calculations that banks frequently use. Subsections: Time Value of Money (TVM) POST /finance/tvm/pv: Calculate Present Value. POST /finance/tvm/fv: Calculate Future Value. POST /finance/tvm/npv: Calculate Net Present Value. POST /finance/tvm/irr: Calculate Internal Rate of Return. POST /finance/tvm/mirr: Calculate Modified Internal Rate of Return. Loan Calculations POST /finance/loan/emi: Calculate Equated Monthly Installment (EMI). POST /finance/loan/amortization-schedule: Generate an amortization schedule. POST /finance/loan/interest-rate: Calculate the effective interest rate. Bond Calculations POST /finance/bond/price: Calculate bond price. POST /finance/bond/yield: Calculate bond yield to maturity. POST /finance/bond/cashflows: Generate bond cash flows. POST /finance/bond/duration: Calculate bond duration (Macaulay, Modified). POST /finance/bond/convexity: Calculate bond convexity. Investment Metrics POST /finance/investment/roi: Calculate Return on Investment (ROI). POST /finance/investment/sharpe-ratio: Calculate Sharpe Ratio. POST /finance/investment/sortino-ratio: Calculate Sortino Ratio. POST /finance/investment/treynor-ratio: Calculate Treynor Ratio. 3. Risk Management Banks need tools to assess and manage financial risk. Subsections: Credit Risk POST /risk/credit/score: Calculate credit score. POST /risk/credit/probability-of-default: Calculate probability of default. POST /risk/credit/loss-given-default: Calculate loss given default. Market Risk POST /risk/market/var: Calculate Value at Risk (VaR). POST /risk/market/cvar: Calculate Conditional Value at Risk (CVaR). POST /risk/market/beta: Calculate portfolio beta. Operational Risk POST /risk/operational/scenario-analysis: Perform scenario analysis. POST /risk/operational/stress-testing: Perform stress testing. 4. Portfolio Management Tools for managing and optimizing investment portfolios. Endpoints: POST /portfolio/optimize: Optimize portfolio for maximum return or minimum risk. POST /portfolio/performance: Calculate portfolio performance metrics. POST /portfolio/rebalance: Rebalance a portfolio based on target allocations. POST /portfolio/correlation: Calculate asset correlations. 5. Regulatory Compliance Banks need to comply with financial regulations. This section provides tools to assist with compliance. Endpoints: POST /compliance/calculate-capital-adequacy: Calculate capital adequacy ratio (Basel III). POST /compliance/liquidity-coverage-ratio: Calculate liquidity coverage ratio (LCR). POST /compliance/stress-test: Perform regulatory stress tests. POST /compliance/anti-money-laundering: Check transactions for AML compliance. 6. Payment Processing Tools for handling payments, transfers, and settlements. Endpoints: POST /payments/process: Process a payment. POST /payments/batch-process: Process multiple payments in bulk. POST /payments/forex-conversion: Convert currency for international payments. POST /payments/settlement: Settle transactions between banks. 7. Reporting & Analytics Generate reports and analytics for banks to monitor their financial health. Endpoints: POST /reports/balance-sheet: Generate a balance sheet report. POST /reports/income-statement: Generate an income statement report. POST /reports/cash-flow: Generate a cash flow statement report. POST /reports/custom: Generate a custom report based on user-defined parameters. 8. Data Management Tools for managing and analyzing financial data. Endpoints: POST /data/upload: Upload financial data (e.g., transaction history, market data). POST /data/clean: Clean and preprocess financial data. POST /data/analyze: Perform statistical analysis on financial data. POST /data/visualize: Generate visualizations (e.g., charts, graphs). 9. Integration & Extensibility Allow banks to integrate the API with their existing systems and extend its functionality. Endpoints: POST /integration/webhook: Set up webhooks for real-time notifications. POST /integration/custom-endpoint: Allow banks to define custom endpoints. POST /integration/plugin: Upload and manage plugins for additional functionality. 10. Documentation & Support Provide comprehensive documentation and support for banks using the API. Endpoints: GET /docs: Access API documentation. POST /support/ticket: Submit a support ticket. GET /support/faq: Access frequently asked questions.

Rate Limits

  • Registration: 5 attempts per minute
  • Login: 5 attempts per minute
  • Addition API: 100 calls per day, 10 calls per minute
  • Email Headers Analysis: 50 calls per day