An r/HalalInvestor post released Yassir v0.1.0 — an OSS Shariah-compliant research agent. Its stack used four web-search vendors plus HalalTerminal. This tutorial consolidates the web layer to Scavio while keeping fundamentals on a specialist API.
Prerequisites
- Python 3.10+ or TypeScript / Bun
- Scavio API key
- Polygon.io free tier
Walkthrough
Step 1: Replace the four-vendor web fallback chain
One Scavio call covers what Brave + Tavily + Exa + Perplexity did.
import requests, os
API_KEY = os.environ['SCAVIO_API_KEY']
def web(q):
return requests.post('https://api.scavio.dev/api/v1/search',
headers={'x-api-key': API_KEY}, json={'query': q}).json()Step 2: Reddit retail-sentiment layer
r/halalinvesting, r/wallstreetbets surface sentiment shifts.
def reddit(q):
return requests.post('https://api.scavio.dev/api/v1/reddit/search',
headers={'x-api-key': API_KEY}, json={'query': q}).json()Step 3: Polygon for fundamentals
Free tier delayed but acceptable for research.
from polygon import RESTClient
client = RESTClient(api_key=os.environ['POLYGON_API_KEY'])
def fundamentals(ticker):
return client.get_ticker_details(ticker)Step 4: Shariah filter in the agent prompt
The LLM applies riba / gharar / haram filters.
RULES = '''
Reject if: interest-bearing debt > 33% of market cap; alcohol/gambling/conventional finance revenue > 5%.
Flag for purification if: small interest income.
'''Step 5: Compose sourced answer
Three surfaces + fundamentals + Shariah filter.
def research(ticker):
return {'web': web(f'{ticker} 2026 financials'), 'reddit': reddit(ticker), 'fundamentals': fundamentals(ticker)}Python Example
# Per-question cost: 2-3 Scavio calls + 1 Polygon call. Total ~$0.013 + Polygon (free tier).JavaScript Example
// TypeScript / Bun version uses the same endpoints.Expected Output
Per-ticker research brief: web summary, retail sentiment, fundamentals, Shariah-compliance verdict.