API Documentation

Complete reference for integrating with AI Tax Analyst SA APIs

Getting Started

Base URL: https://your-domain.replit.app/api

Content-Type: application/json

All API responses include a success boolean field and relevant data or error messages.

API Endpoints

POST /api/calculate-paye ACTIVE

PAYE Tax Calculator

Calculate Pay-As-You-Earn tax for individual taxpayers based on annual salary.

Request Parameters
Parameter Type Required Description
annual_salary number Yes Annual salary in Rands (e.g., 500000)
age number No Age of taxpayer (affects rebates)
tax_year string No Tax year (default: 2025/2026)
Example Request
{
  "annual_salary": 500000,
  "age": 35,
  "tax_year": "2025/2026"
}
Example Response
{
  "success": true,
  "calculation": {
    "annual_salary": 500000.0,
    "gross_tax": 112532.0,
    "net_tax": 95297.0,
    "rebates_applied": 17235,
    "net_annual_salary": 404703.0,
    "monthly": {
      "gross_salary": 41666.67,
      "tax": 7941.42,
      "net_salary": 33725.25
    },
    "rates": {
      "effective_rate": 19.06,
      "marginal_rate": 31.0
    },
    "tax_year": "2025/2026",
    "calculation_date": "2025-09-24"
  }
}
Integration Example
import requests

url = "https://your-domain.replit.app/api/calculate-paye"
data = {
    "annual_salary": 500000,
    "age": 35
}

response = requests.post(url, json=data)
result = response.json()

if result["success"]:
    calc = result["calculation"]
    print(f"Monthly Tax: R{calc['monthly']['tax']:,.2f}")
    print(f"Net Salary: R{calc['monthly']['net_salary']:,.2f}")
const response = await fetch('https://your-domain.replit.app/api/calculate-paye', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        annual_salary: 500000,
        age: 35
    })
});

const result = await response.json();
if (result.success) {
    console.log(`Monthly Tax: R${result.calculation.monthly.tax}`);
}
curl -X POST https://your-domain.replit.app/api/calculate-paye \
  -H "Content-Type: application/json" \
  -d '{"annual_salary": 500000, "age": 35}'
POST /api/calculate-company-tax ACTIVE

Company Tax Calculator

Calculate corporate income tax for South African companies.

Request Parameters
Parameter Type Required Description
taxable_income number Yes Company's taxable income in Rands
company_type string No Type: "normal", "sbc" (Small Business Corporation), "micro"
Example Request
{
  "taxable_income": 1000000,
  "company_type": "normal"
}
Example Response
{
  "success": true,
  "calculation": {
    "taxable_income": 1000000.0,
    "tax_rate": 27.0,
    "tax_amount": 270000.0,
    "net_income": 730000.0,
    "company_type": "normal",
    "effective_rate": 27.0
  }
}
POST /api/calculate-vat ACTIVE

VAT Calculator

Calculate VAT amounts for transactions at the standard 15% rate.

Request Parameters
Parameter Type Required Description
amount number Yes Amount in Rands
vat_inclusive boolean No Whether amount includes VAT (default: false)
vat_rate number No VAT rate percentage (default: 15)
Example Request
{
  "amount": 1000,
  "vat_inclusive": false
}
Example Response
{
  "success": true,
  "calculation": {
    "amount_excl_vat": 1000.0,
    "vat_amount": 150.0,
    "amount_incl_vat": 1150.0,
    "vat_rate": 15.0
  }
}
POST /api/universal ACTIVE

Universal AI Query

Intelligent routing system that automatically determines whether to perform calculations, search the knowledge base, or provide AI-generated responses based on query intent.

Request Parameters
Parameter Type Required Description
query string Yes Natural language query about SA tax
context object No Additional context for the query
Query Types Supported
  • Tax Calculations: "Calculate PAYE for R500,000 salary"
  • Legal Questions: "What is the VAT rate in South Africa?"
  • Procedural Guidance: "How do I register for VAT?"
  • Document Analysis: "Explain provisional tax requirements"
Example Request
{
  "query": "What are the PAYE tax brackets for 2025?"
}
Example Response
{
  "success": true,
  "intent": "qa",
  "confidence": 0.95,
  "result": {
    "answer": "For the 2025/2026 tax year, the PAYE tax brackets are...",
    "sources": [
      {
        "source": "SARS Tax Tables 2025/2026",
        "similarity": 0.89,
        "text": "Tax bracket information..."
      }
    ],
    "confidence": 0.85
  }
}
POST /api/analyze-document ACTIVE

Document Analysis

Upload and analyze tax documents using AI to extract key information and provide insights.

Request Format

This endpoint accepts multipart/form-data for file uploads.

Request Parameters
Parameter Type Required Description
file file Yes PDF or text document (max 10MB)
analysis_type string No Type: "summary", "extract", "compliance"
Example Request (Python)
import requests

url = "https://your-domain.replit.app/api/analyze-document"
files = {'file': open('tax_return.pdf', 'rb')}
data = {'analysis_type': 'summary'}

response = requests.post(url, files=files, data=data)
result = response.json()
Example Response
{
  "success": true,
  "analysis": {
    "document_type": "Tax Return",
    "key_information": {
      "tax_year": "2024/2025",
      "taxpayer_type": "Individual",
      "total_income": 650000
    },
    "summary": "This document is an individual tax return...",
    "compliance_notes": [],
    "recommendations": []
  }
}
POST /api/ask ACTIVE

AI Question & Answer

Direct AI-powered Q&A endpoint using RAG (Retrieval Augmented Generation) for accurate tax-related questions with source citations.

Request Parameters
Parameter Type Required Description
question string Yes Tax-related question (5-500 characters)
Example Request
{
  "question": "How do I claim home office expenses?"
}
Example Response
{
  "success": true,
  "answer": "To claim home office expenses in South Africa, you must meet specific SARS requirements...",
  "sources": [
    {
      "source": "SARS Home Office Guide",
      "similarity": 0.92,
      "text": "Home office expenses can be claimed if..."
    }
  ],
  "question": "How do I claim home office expenses?",
  "response_time": 1.234
}
Rate Limiting

This endpoint is limited to 20 requests per hour per IP address.

GET /api/documents ACTIVE

List Documents

Retrieve a list of available documents in the knowledge base.

Query Parameters
Parameter Type Required Description
category string No Filter by category
processed boolean No Filter by processing status
Example Response
{
  "success": true,
  "documents": [
    {
      "id": 1,
      "filename": "income_tax_act.pdf",
      "category": "Legislation",
      "processed": true,
      "page_count": 450,
      "upload_date": "2025-09-01"
    }
  ],
  "total": 25
}

Error Handling

All API endpoints return consistent error responses:

Error Response Format
{
  "success": false,
  "error": "Error message describing the issue",
  "code": "ERROR_CODE",
  "details": {} // Optional additional error details
}
Common Error Codes
HTTP Status Error Code Description
400 INVALID_REQUEST Missing or invalid parameters
404 NOT_FOUND Resource not found
413 FILE_TOO_LARGE Uploaded file exceeds size limit
429 RATE_LIMIT Too many requests
500 INTERNAL_ERROR Server error

Rate Limiting

API endpoints have the following rate limits to ensure fair usage:

Endpoint Type Rate Limit Window
Calculation APIs 100 requests per minute
AI Query APIs 30 requests per minute
Document Analysis 10 requests per minute
Search APIs 60 requests per minute

Rate limit information is included in response headers:

  • X-RateLimit-Limit: Maximum requests allowed
  • X-RateLimit-Remaining: Requests remaining
  • X-RateLimit-Reset: Unix timestamp when limit resets

SDKs & Libraries

Quick Start Examples

Get started quickly with our API using these code examples:

Python SDK Example
# Install: pip install requests

import requests

class TaxAnalystAPI:
    def __init__(self, base_url):
        self.base_url = base_url
        self.session = requests.Session()
    
    def calculate_paye(self, annual_salary, age=None):
        """Calculate PAYE tax for an individual"""
        data = {"annual_salary": annual_salary}
        if age:
            data["age"] = age
        
        response = self.session.post(
            f"{self.base_url}/api/calculate-paye",
            json=data
        )
        return response.json()
    
    def query_ai(self, question):
        """Ask a tax-related question"""
        response = self.session.post(
            f"{self.base_url}/api/universal",
            json={"query": question}
        )
        return response.json()

# Usage
api = TaxAnalystAPI("https://your-domain.replit.app")
result = api.calculate_paye(500000, age=35)
print(f"Monthly net salary: R{result['calculation']['monthly']['net_salary']:,.2f}")
Node.js Example
// Install: npm install axios

const axios = require('axios');

class TaxAnalystAPI {
    constructor(baseUrl) {
        this.baseUrl = baseUrl;
    }
    
    async calculatePAYE(annualSalary, age = null) {
        const data = { annual_salary: annualSalary };
        if (age) data.age = age;
        
        const response = await axios.post(
            `${this.baseUrl}/api/calculate-paye`,
            data
        );
        return response.data;
    }
    
    async queryAI(question) {
        const response = await axios.post(
            `${this.baseUrl}/api/universal`,
            { query: question }
        );
        return response.data;
    }
}

// Usage
const api = new TaxAnalystAPI('https://your-domain.replit.app');
api.calculatePAYE(500000, 35).then(result => {
    console.log(`Monthly tax: R${result.calculation.monthly.tax}`);
});

Need Help?

Our API is designed to be simple and intuitive. If you need assistance:

Documentation

Review this comprehensive API documentation

Examples

Check the code examples for your language

Support

Contact our technical support team

Legal Disclaimer

This API provides tax calculation and information services based on South African tax legislation. All calculations and information are provided for general guidance only. Users should verify all information with SARS and consult qualified tax professionals for specific advice. The API maintainers accept no liability for decisions made based on the information provided.