<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Yassir</title>
    <description>The latest articles on DEV Community by Yassir (@yassir0).</description>
    <link>https://dev.to/yassir0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4056992%2F66e205a9-fa86-4d97-aa7f-c812af235186.jpg</url>
      <title>DEV Community: Yassir</title>
      <link>https://dev.to/yassir0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yassir0"/>
    <language>en</language>
    <item>
      <title>Build a Halal Stock Screener with Python</title>
      <dc:creator>Yassir</dc:creator>
      <pubDate>Fri, 31 Jul 2026 17:31:47 +0000</pubDate>
      <link>https://dev.to/yassir0/build-a-halal-stock-screener-with-python-34a0</link>
      <guid>https://dev.to/yassir0/build-a-halal-stock-screener-with-python-34a0</guid>
      <description>&lt;h2&gt;
  
  
  What We're Building
&lt;/h2&gt;

&lt;p&gt;By the end of this tutorial, you'll have a Python script that can:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Screen any stock for Shariah compliance across 5 methodologies&lt;/li&gt;
&lt;li&gt;Bulk-screen an entire index (S&amp;amp;P 500, NASDAQ 100, etc.)&lt;/li&gt;
&lt;li&gt;Scan a portfolio and calculate aggregate compliance&lt;/li&gt;
&lt;li&gt;Pull dividend purification data&lt;/li&gt;
&lt;li&gt;Export everything to CSV&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Total code: ~80 lines. Total time: ~15 minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Python 3.8+&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;requests&lt;/strong&gt; library (&lt;code&gt;pip install requests&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;A free Halal Terminal API key (we'll generate one in Step 1)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Get an API Key
&lt;/h2&gt;

&lt;p&gt;First, generate a free API key. No credit card required -- the free tier includes 500 tokens/month:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import requests

BASE_URL = "https://api.halalterminal.com"

# Generate a free API key
resp = requests.post(f"{BASE_URL}/api/keys/generate", json={
    "email": "dev@example.com"
})
data = resp.json()
API_KEY = data["api_key"]
print(f"Your API key: {API_KEY}")
print(f"Plan: {data['plan']}, Tokens: {data['requests_limit']}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Save your API key -- you'll use it in every subsequent request via the &lt;code&gt;X-API-Key&lt;/code&gt; header.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Screen a Single Stock
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;/api/screen&lt;/code&gt; endpoint is the core of the API. It returns compliance status for all five Shariah screening methodologies in a single call:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;headers = {"X-API-Key": API_KEY}

def screen_stock(symbol):
    """Screen a stock for Shariah compliance."""
    resp = requests.get(
        f"{BASE_URL}/api/screen",
        params={"symbol": symbol},
        headers=headers,
    )
    resp.raise_for_status()
    return resp.json()

# Screen Apple
result = screen_stock("AAPL")
print(f"{result['symbol']}: {result['overall_status']}")
for method, status in result["methodologies"].items():
    print(f"  {method}: {status}")
print(f"  Purification rate: {result['purification_rate']}%")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AAPL: COMPLIANT
  AAOIFI: COMPLIANT
  DJIM: COMPLIANT
  FTSE: COMPLIANT
  MSCI: COMPLIANT
  SP: COMPLIANT
  Purification rate: 0.42%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Token Costs&lt;/p&gt;

&lt;p&gt;Each API endpoint costs a specific number of tokens. Single stock screening costs &lt;strong&gt;5 tokens&lt;/strong&gt; , so with the free plan's 500 tokens, you can screen 100 stocks per month. Upgrade to Starter ($19/mo) for 2,500 tokens or Pro ($49/mo) for 15,000 tokens. See the full cost table at &lt;code&gt;/api/keys/token-costs&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Bulk Screen an Entire Index
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;/api/screen-bulk&lt;/code&gt; endpoint lets you screen an entire index asynchronously. Submit a list of symbols and get results for all of them:&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def bulk_screen(symbols):&lt;br&gt;
    """Screen multiple stocks at once."""&lt;br&gt;
    resp = requests.post(&lt;br&gt;
        f"{BASE_URL}/api/screen-bulk",&lt;br&gt;
        json={"symbols": symbols},&lt;br&gt;
        headers=headers,&lt;br&gt;
    )&lt;br&gt;
    resp.raise_for_status()&lt;br&gt;
    return resp.json()
&lt;h1&gt;
  
  
  Screen the FAANG stocks
&lt;/h1&gt;

&lt;p&gt;faang = ["AAPL", "AMZN", "GOOGL", "META", "NFLX"]&lt;br&gt;
results = bulk_screen(faang)&lt;/p&gt;

&lt;p&gt;print(f"\nBulk screening results ({len(results['results'])} stocks):")&lt;br&gt;
for stock in results["results"]:&lt;br&gt;
    status = stock["overall_status"]&lt;br&gt;
    emoji = "PASS" if status == "COMPLIANT" else "FAIL"&lt;br&gt;
    print(f"  [{emoji}] {stock['symbol']}: {status}")&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Step 4: Portfolio Compliance Scanner&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;/api/portfolio/scan&lt;/code&gt; endpoint takes your actual holdings (with share counts) and returns per-stock compliance plus aggregate portfolio metrics:&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def scan_portfolio(holdings):&lt;br&gt;
    """Scan a portfolio for Shariah compliance."""&lt;br&gt;
    resp = requests.post(&lt;br&gt;
        f"{BASE_URL}/api/portfolio/scan",&lt;br&gt;
        json={"holdings": holdings},&lt;br&gt;
        headers=headers,&lt;br&gt;
    )&lt;br&gt;
    resp.raise_for_status()&lt;br&gt;
    return resp.json()
&lt;h1&gt;
  
  
  Define your portfolio
&lt;/h1&gt;

&lt;p&gt;my_portfolio = [&lt;br&gt;
    {"symbol": "AAPL", "shares": 50},&lt;br&gt;
    {"symbol": "MSFT", "shares": 30},&lt;br&gt;
    {"symbol": "GOOGL", "shares": 20},&lt;br&gt;
    {"symbol": "JPM", "shares": 15},   # Bank - likely non-compliant&lt;br&gt;
    {"symbol": "NVDA", "shares": 25},&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;portfolio = scan_portfolio(my_portfolio)&lt;br&gt;
print(f"\nPortfolio Compliance Report")&lt;br&gt;
print(f"{'='*40}")&lt;br&gt;
print(f"Compliant holdings: {portfolio['compliant_count']}/{portfolio['total_count']}")&lt;br&gt;
print(f"Compliance rate: {portfolio['compliance_rate']}%")&lt;br&gt;
print(f"Portfolio purification rate: {portfolio['purification_rate']}%")&lt;br&gt;
print(f"\nPer-stock breakdown:")&lt;br&gt;
for stock in portfolio["holdings"]:&lt;br&gt;
    status = stock["overall_status"]&lt;br&gt;
    print(f"  {stock['symbol']:6s} {status}")&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Step 5: Add Dividend Purification Data&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;For compliant holdings that pay dividends, fetch the purification details:&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def get_purification(symbol):&lt;br&gt;
    """Get dividend purification data for a stock."""&lt;br&gt;
    resp = requests.get(&lt;br&gt;
        f"{BASE_URL}/api/dividends/{symbol}/purification",&lt;br&gt;
        headers=headers,&lt;br&gt;
    )&lt;br&gt;
    resp.raise_for_status()&lt;br&gt;
    return resp.json()
&lt;h1&gt;
  
  
  Get purification data for dividend-paying holdings
&lt;/h1&gt;

&lt;p&gt;for holding in my_portfolio:&lt;br&gt;
    symbol = holding["symbol"]&lt;br&gt;
    try:&lt;br&gt;
        purification = get_purification(symbol)&lt;br&gt;
        rate = purification["purification_rate"]&lt;br&gt;
        print(f"{symbol}: purification rate = {rate}%")&lt;br&gt;
    except requests.HTTPError:&lt;br&gt;
        print(f"{symbol}: no purification data available")&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Step 6: Export Results to CSV&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;Finally, let's export everything into a clean CSV report:&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import csv

&lt;p&gt;def export_to_csv(portfolio_data, filename="shariah_report.csv"):&lt;br&gt;
    """Export portfolio screening results to CSV."""&lt;br&gt;
    with open(filename, "w", newline="") as f:&lt;br&gt;
        writer = csv.writer(f)&lt;br&gt;
        writer.writerow([&lt;br&gt;
            "Symbol", "Status", "AAOIFI", "DJIM", "FTSE",&lt;br&gt;
            "MSCI", "SP", "Purification Rate"&lt;br&gt;
        ])&lt;br&gt;
        for stock in portfolio_data["holdings"]:&lt;br&gt;
            methods = stock.get("methodologies", {})&lt;br&gt;
            writer.writerow([&lt;br&gt;
                stock["symbol"],&lt;br&gt;
                stock["overall_status"],&lt;br&gt;
                methods.get("AAOIFI", "N/A"),&lt;br&gt;
                methods.get("DJIM", "N/A"),&lt;br&gt;
                methods.get("FTSE", "N/A"),&lt;br&gt;
                methods.get("MSCI", "N/A"),&lt;br&gt;
                methods.get("SP", "N/A"),&lt;br&gt;
                stock.get("purification_rate", "N/A"),&lt;br&gt;
            ])&lt;br&gt;
    print(f"Report saved to {filename}")&lt;/p&gt;

&lt;p&gt;export_to_csv(portfolio)&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Endpoint Reference&lt;br&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Tokens&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/api/screen&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Screen a single stock&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/api/screen-bulk&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;POST&lt;/td&gt;
&lt;td&gt;50&lt;/td&gt;
&lt;td&gt;Bulk screen multiple stocks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/api/portfolio/scan&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;POST&lt;/td&gt;
&lt;td&gt;25&lt;/td&gt;
&lt;td&gt;Scan portfolio compliance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/api/dividends/{symbol}/purification&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Get purification data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/api/etf/{symbol}/screening&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;Screen ETF holdings&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/api/quote/{symbol}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Get stock quote&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/api/zakat/calculate&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;POST&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Calculate zakat on portfolio&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/api/database/search&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Search stock database&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Build with Halal Terminal&lt;/p&gt;

&lt;h3&gt;
  
  
  Halal Terminal API
&lt;/h3&gt;

&lt;p&gt;58+ endpoints, 5 screening methodologies, ETF analysis, zakat calculators, and MCP tools. Free tier available.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.halalterminal.com/product/api" rel="noopener noreferrer"&gt;Explore the API -&amp;gt;&lt;/a&gt; &lt;a href="https://www.halalterminal.com/terminal" rel="noopener noreferrer"&gt;Try the Terminal instead&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;You now have a working Shariah stock screener in Python. Here are some ideas to extend it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Build a web dashboard&lt;/strong&gt; -- Use Flask or FastAPI to create a web UI for your screener&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add scheduling&lt;/strong&gt; -- Run portfolio compliance checks daily or weekly using cron&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrate with your broker&lt;/strong&gt; -- Pull holdings from Interactive Brokers, Alpaca, or Wealthsimple and auto-screen&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build alerts&lt;/strong&gt; -- Notify when a holding's compliance status changes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add zakat tracking&lt;/strong&gt; -- Use the &lt;code&gt;/api/zakat/calculate&lt;/code&gt; endpoint to track your annual obligation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the full API reference with all 58+ endpoints, visit the &lt;a href="https://api.halalterminal.com/docs" rel="noopener noreferrer"&gt;Swagger documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Important Disclaimer
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Not financial advice.&lt;/strong&gt; The information provided on this page is for educational and informational purposes only and should not be construed as financial advice, investment advice, trading advice, or any other type of advice. You should not make any financial decisions based solely on the information presented here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not a fatwa.&lt;/strong&gt; Shariah compliance screening results are generated using automated data analysis based on publicly available financial data. These results do not constitute a religious ruling (fatwa) and should not be treated as one. Always consult a qualified Islamic scholar or Shariah advisor for guidance specific to your situation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do your own research.&lt;/strong&gt; Past performance and current compliance status do not guarantee future results or continued compliance. Screening data may contain errors or become outdated. Always verify information independently and consult with a qualified financial advisor before making any investment decisions.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://api.halalterminal.com/blog/posts/build-halal-stock-screener-python" rel="noopener noreferrer"&gt;Halal Terminal blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>tutorial</category>
      <category>finance</category>
      <category>api</category>
    </item>
    <item>
      <title>Halal API quickstart in 10 lines — Python &amp;amp; JavaScript SDKs</title>
      <dc:creator>Yassir</dc:creator>
      <pubDate>Fri, 31 Jul 2026 17:26:04 +0000</pubDate>
      <link>https://dev.to/yassir0/halal-api-quickstart-in-10-lines-python-amp-javascript-sdks-e2e</link>
      <guid>https://dev.to/yassir0/halal-api-quickstart-in-10-lines-python-amp-javascript-sdks-e2e</guid>
      <description>&lt;p&gt;Today we're shipping two official SDKs for the Halal Terminal API: &lt;code&gt;halalterminal&lt;/code&gt; on PyPI and &lt;code&gt;@halalterminal/sdk&lt;/code&gt; on npm. Same surface in both languages: typed screening responses, a typed &lt;code&gt;disclaimers&lt;/code&gt; array on every relevant call, granular error classes, and a generic GET/POST escape hatch for the long tail of endpoints.&lt;/p&gt;

&lt;p&gt;If you've been hitting &lt;code&gt;curl https://api.halalterminal.com&lt;/code&gt; from a script, this is the upgrade path. If you're new: this is the fastest way to ship a Shariah-aware feature into your app.&lt;/p&gt;

&lt;h2&gt;
  
  
  10 lines that screen a stock
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install halalterminal


from halalterminal import Client

ht = Client(api_key="ht_…")               # or set HALAL_TERMINAL_API_KEY

aapl = ht.screen("AAPL")
print(aapl.is_compliant, aapl.compliance_explanation)

for d in aapl.disclaimers:                # render these inline in your UI
    print(f"[{d.severity}] {d.text}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;TypeScript / JavaScript:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @halalterminal/sdk


import { HalalTerminal } from "@halalterminal/sdk";

const ht = new HalalTerminal({ apiKey: process.env.HALAL_TERMINAL_API_KEY });

const aapl = await ht.screen("AAPL");
console.log(aapl.is_compliant, aapl.compliance_explanation);

for (const d of aapl.disclaimers) {
  console.log(`[${d.severity}] ${d.text}`);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That's it. Both calls return the same shape, audited against the 5 published Shariah methodologies (AAOIFI, DJIM, FTSE, MSCI, S&amp;amp;P) -- with DJIM and S&amp;amp;P now using their spec-required 24-month and 36-month trailing-average market cap, not spot MC. Every per-methodology entry carries a &lt;code&gt;verified: true&lt;/code&gt; audit flag.&lt;/p&gt;

&lt;h2&gt;
  
  
  Need a key? It's free.
&lt;/h2&gt;

&lt;p&gt;Generate one with a single POST -- no credit card, no waiting list:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -X POST https://api.halalterminal.com/api/keys/generate \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com"}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The free tier ships 500 tokens / month. Screening a single stock costs ~5 tokens; checking compliance on a portfolio of 10 names costs ~15. Upgrade to Starter ($19/mo) for 2,500 tokens, Pro ($49/mo) for 15,000 plus webhooks, or Enterprise ($199/mo) for 50,000 with $0.005/token overage.&lt;/p&gt;

&lt;h2&gt;
  
  
  What both SDKs ship with
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Typed screening responses.&lt;/strong&gt; &lt;code&gt;ScreeningResult&lt;/code&gt; has &lt;code&gt;is_compliant&lt;/code&gt;, &lt;code&gt;shariah_compliance_status&lt;/code&gt;, &lt;code&gt;purification_rate&lt;/code&gt;, &lt;code&gt;by_methodology&lt;/code&gt;, and a plain-English &lt;code&gt;compliance_explanation&lt;/code&gt;. Forward-compatible: unknown server fields stay on the raw object so the SDK never crashes on new API additions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Typed disclaimers.&lt;/strong&gt; Every relevant response carries a &lt;code&gt;disclaimers&lt;/code&gt; array. Each entry has a stable &lt;code&gt;id&lt;/code&gt;, an ISO &lt;code&gt;version&lt;/code&gt;, a &lt;code&gt;severity&lt;/code&gt; (&lt;code&gt;religious&lt;/code&gt; for fatwa caveats, &lt;code&gt;data&lt;/code&gt; for freshness / sourcing), and a &lt;code&gt;url&lt;/code&gt; that deep-links to the right section on the legal page. Render them inline -- the API ships your compliance copy for you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Granular errors.&lt;/strong&gt; &lt;code&gt;ApiKeyError&lt;/code&gt; / &lt;code&gt;NotFoundError&lt;/code&gt; / &lt;code&gt;RateLimitError&lt;/code&gt; / &lt;code&gt;QuotaExceededError&lt;/code&gt; / &lt;code&gt;ServerError&lt;/code&gt;. Catch the ones you care about (typically &lt;code&gt;QuotaExceededError&lt;/code&gt; to trigger an upgrade flow); everything else falls through to &lt;code&gt;HalalTerminalError&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Escape hatch.&lt;/strong&gt; The SDKs wrap the most-used endpoints; for the long tail, &lt;code&gt;ht.get("/api/...")&lt;/code&gt; and &lt;code&gt;ht.post("/api/...", body)&lt;/code&gt; return parsed JSON.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero ceremony.&lt;/strong&gt; Python: one runtime dep (&lt;code&gt;requests&lt;/code&gt;). JS: zero deps, uses the platform's &lt;code&gt;fetch&lt;/code&gt;. Both work in serverless / edge runtimes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A more involved example: zakat at the end of the year
&lt;/h2&gt;

&lt;p&gt;Computing zakat on a stock portfolio is a common one-time task. Here's the whole thing in Python:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from halalterminal import Client

ht = Client()  # uses HALAL_TERMINAL_API_KEY env var

z = ht.calculate_zakat([
    {"symbol": "AAPL", "market_value": 25_000},
    {"symbol": "MSFT", "market_value": 18_000},
    {"symbol": "GOOGL", "market_value": 12_000},
])

if z.is_above_nisab:
    print(f"You owe ${z.total_zakat:,.2f} in zakat on ${z.total_market_value:,.2f} of holdings.")
else:
    print(f"Below the nisab threshold (${z.nisab_threshold:,.2f}); no zakat owed this year.")

for d in z.disclaimers:
    print(f"-- {d.text}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The zakat disclaimer ships with the response -- it names exactly what the simplified calculation excludes (the silver-nisab alternative, the &lt;em&gt;hawl&lt;/em&gt; requirement, business-inventory rules, liability deductions) so you can surface it to the user without writing your own.&lt;/p&gt;

&lt;h2&gt;
  
  
  Portfolio scan in TypeScript
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { HalalTerminal } from "@halalterminal/sdk";

&lt;p&gt;const ht = new HalalTerminal();&lt;/p&gt;

&lt;p&gt;const scan = await ht.scanPortfolio(["AAPL", "MSFT", "JNJ", "BAC", "JPM"]);&lt;br&gt;
console.log(&lt;br&gt;
  &lt;code&gt;${scan.summary.compliant} compliant, ${scan.summary.non_compliant} non-compliant out of ${scan.summary.total}.&lt;/code&gt;,&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;// Per-symbol detail is on scan.results&lt;br&gt;
for (const r of scan.results) {&lt;br&gt;
  console.log(r.symbol, r.is_compliant);&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Why we built typed disclaimers in&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;Most halal-data APIs make you assemble "not a fatwa" copy yourself, hand it to legal review, and bolt it onto your UI as a static string. That copy then drifts: scholars update their guidance, the methodology gains a caveat, the upstream data source adds a delay disclosure -- and your bolt-on copy is two quarters stale.&lt;/p&gt;

&lt;p&gt;The Halal Terminal API attaches the disclaimer to the response. The SDKs unpack it as a typed object. When the registry advances (the &lt;code&gt;version&lt;/code&gt; field is an ISO date), you can detect the change and re-prompt the user to acknowledge. &lt;code&gt;severity&lt;/code&gt; lets you visually group the fatwa caveats separately from the data-freshness ones. &lt;code&gt;url&lt;/code&gt; deep-links to the long-form text so you don't have to host your own.&lt;/p&gt;

&lt;p&gt;For a regulated-fintech buyer, this is what compliance review actually asks for. For a solo dev, it's one less file to maintain.&lt;/p&gt;

&lt;h2&gt;
  
  
  The escape hatch in action
&lt;/h2&gt;

&lt;p&gt;The API surfaces 60+ endpoints; the SDK wraps the dozen most-used. Anything else:&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Python&lt;br&gt;
trending = ht.get("/api/trending")&lt;br&gt;
report   = ht.post("/api/reports/portfolio", json={"symbols": ["AAPL", "MSFT"]})

&lt;p&gt;// TypeScript&lt;br&gt;
const trending = await ht.get&amp;gt;("/api/trending");&lt;br&gt;
const report   = await ht.post("/api/reports/portfolio", { symbols: ["AAPL", "MSFT"] });&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  What's next on the SDK roadmap&lt;br&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Async Python client (&lt;code&gt;AsyncClient&lt;/code&gt; on top of &lt;code&gt;httpx&lt;/code&gt;) for FastAPI / asyncio users.&lt;/li&gt;
&lt;li&gt;Streaming endpoints (bulk-screen progress) once the server side exposes SSE.&lt;/li&gt;
&lt;li&gt;Type-safe response models for ETF look-through, dividend purification, and news.&lt;/li&gt;
&lt;li&gt;Optional automatic retry-with-backoff on 5xx / network errors.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to vote on what lands first, or you've hit a rough edge, the SDKs are open-source: &lt;a href="https://github.com/goww7/FinanceData2/tree/main/sdks" rel="noopener noreferrer"&gt;github.com/goww7/FinanceData2/tree/main/sdks&lt;/a&gt;. PRs welcome.&lt;/p&gt;

&lt;p&gt;Build with Halal Terminal&lt;/p&gt;

&lt;h3&gt;
  
  
  Halal Terminal API
&lt;/h3&gt;

&lt;p&gt;58+ endpoints. 5 verified Shariah methodologies. Inline disclaimers shipped on every response. Free tier with 500 tokens/month.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://api.halalterminal.com/subscribe?plan=free" rel="noopener noreferrer"&gt;Get a free API key -&amp;gt;&lt;/a&gt; &lt;a href="https://api.halalterminal.com/docs" rel="noopener noreferrer"&gt;Browse the full API docs&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Important Disclaimer
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Not financial advice.&lt;/strong&gt; The information presented here is for developer education and informational purposes only. Nothing on this page constitutes financial advice, investment advice, or a recommendation to buy or sell any security.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not a fatwa.&lt;/strong&gt; The compliance verdicts returned by the Halal Terminal API are produced by automated screening of public financial filings against the 5 published methodologies. They are not a scholarly attestation or religious ruling. Consult a qualified Islamic scholar for personal religious decisions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do your own diligence.&lt;/strong&gt; Past compliance does not guarantee future compliance. Data may be delayed, restated, or contain errors. Verify before acting.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://api.halalterminal.com/blog/posts/halal-api-quickstart-python-javascript" rel="noopener noreferrer"&gt;Halal Terminal blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>javascript</category>
      <category>api</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Connect Claude to Shariah Stock Screening in 5 Minutes (MCP)</title>
      <dc:creator>Yassir</dc:creator>
      <pubDate>Fri, 31 Jul 2026 17:25:59 +0000</pubDate>
      <link>https://dev.to/yassir0/connect-claude-to-shariah-stock-screening-in-5-minutes-mcp-3hjp</link>
      <guid>https://dev.to/yassir0/connect-claude-to-shariah-stock-screening-in-5-minutes-mcp-3hjp</guid>
      <description>&lt;p&gt;The Model Context Protocol (MCP) lets an AI client call external tools directly. Connect the Halal Terminal MCP server and your assistant can screen any stock or ETF for Shariah compliance in plain language, no copy-pasting tickers into a dashboard. This guide gets you from zero to a working setup in about five minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you get
&lt;/h2&gt;

&lt;p&gt;Once connected, you can ask questions like &lt;em&gt;"Is AAPL halal?"&lt;/em&gt; or &lt;em&gt;"Audit this portfolio: AAPL, MSFT, GOOGL"&lt;/em&gt; straight inside Claude Desktop, Claude Code, Cursor, or any other MCP client (Windsurf, Cline, Continue, Zed, Goose). The assistant picks the right tool, calls the API, and answers with real data.&lt;/p&gt;

&lt;p&gt;The server exposes &lt;strong&gt;22 tools&lt;/strong&gt; across eight categories: stock and ETF screening across 5 methodologies (AAOIFI, DJIM, FTSE, MSCI, S&amp;amp;P), bulk index screens, live quotes and price history, ETF holdings analysis, portfolio and watchlist scans, dividend and zakat calculators, news and SEC filings, plus report and education helpers. Every verdict is a methodology-based screen, not a fatwa.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Get a free API key
&lt;/h2&gt;

&lt;p&gt;Sign up at &lt;a href="https://api.halalterminal.com" rel="noopener noreferrer"&gt;api.halalterminal.com&lt;/a&gt;. It is email-only, no credit card, and the key lands in your inbox in seconds. The free tier includes &lt;strong&gt;500 tokens per month&lt;/strong&gt; , which is plenty to evaluate the server before upgrading. Your key looks like &lt;code&gt;ht_yourkey&lt;/code&gt;. Keep it handy for the next step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Connect your client
&lt;/h2&gt;

&lt;p&gt;The fastest transport is the hosted SSE endpoint. For clients that need a local bridge, the &lt;code&gt;@halalterminal/mcp&lt;/code&gt; package wraps it as stdio, and needs no install thanks to &lt;code&gt;npx&lt;/code&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Recommended - no install needed
npx -y @halalterminal/mcp

# Or pin globally
npm install -g @halalterminal/mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Claude Desktop
&lt;/h3&gt;

&lt;p&gt;Open Settings, go to Developer, edit the config file, and add the server. Swap in your own key, then restart Claude Desktop:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "mcpServers": {
    "halalterminal": {
      "command": "npx",
      "args": ["-y", "@halalterminal/mcp"],
      "env": { "HALALTERMINAL_API_KEY": "ht_yourkey" }
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Claude Code
&lt;/h3&gt;

&lt;p&gt;One command from your terminal registers the hosted server over SSE:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;claude mcp add --transport sse halalterminal \
  https://mcp.halalterminal.com/sse \
  --header "X-API-Key: ht_yourkey"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Cursor, Windsurf, or any direct SSE client
&lt;/h3&gt;

&lt;p&gt;Point the client at the SSE URL with your key as a query parameter:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://mcp.halalterminal.com/sse?api_key=ht_yourkey
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That is it. The client discovers all 22 tools automatically. Auth is either the &lt;code&gt;X-API-Key&lt;/code&gt; header or the &lt;code&gt;?api_key=&lt;/code&gt; query parameter, whichever your client supports.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Ask your first questions
&lt;/h2&gt;

&lt;p&gt;Type these as normal chat messages. The assistant maps each one to a tool and returns live results.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;"Is AAPL halal?"&lt;/strong&gt; calls &lt;code&gt;screen_stock&lt;/code&gt; and returns a verdict under each of the 5 methodologies side by side. On our live screen at publication, Apple came back compliant across all five (AAOIFI, DJIM, FTSE, MSCI, and S&amp;amp;P). Verdicts move with the financials, so always trust the fresh result over any snapshot.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Scan this portfolio: AAPL, MSFT, GOOGL"&lt;/strong&gt; calls &lt;code&gt;scan_portfolio&lt;/code&gt; and returns a per-holding verdict plus an overall compliant percentage for the basket.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Calculate zakat on my holdings"&lt;/strong&gt; calls &lt;code&gt;calculate_zakat&lt;/code&gt;, applying 2.5% against a live nisab threshold once you give it your positions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Compare SPUS vs HLAL"&lt;/strong&gt; calls &lt;code&gt;compare_etfs&lt;/code&gt; and lines up the two funds on compliant percentage, holdings, and aggregate purification rate so you can judge which fits your standard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"What is dividend purification for this stock?"&lt;/strong&gt; calls &lt;code&gt;get_dividends&lt;/code&gt; with purification enabled, computing the non-compliant fraction to donate.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because the assistant reads the structured response, it can chain calls too: screen a stock, then pull its recent news and SEC filings in the same conversation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Token costs
&lt;/h2&gt;

&lt;p&gt;The API is token-metered, not request-metered. Typical calls cost roughly &lt;strong&gt;1 to 5 tokens&lt;/strong&gt; : a full stock screen is 5 tokens, so the free plan's 500 tokens covers about 100 screenings per month. Lighter reads like a quote or a search cost less. You can see the full per-endpoint table at &lt;a href="https://api.halalterminal.com/api/keys/token-costs" rel="noopener noreferrer"&gt;&lt;code&gt;/api/keys/token-costs&lt;/code&gt;&lt;/a&gt;, and check your remaining balance any time from the &lt;a href="https://api.halalterminal.com" rel="noopener noreferrer"&gt;dashboard&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Build with Halal Terminal&lt;/p&gt;

&lt;h3&gt;
  
  
  Halal Terminal API
&lt;/h3&gt;

&lt;p&gt;22 MCP tools, 5 screening methodologies, ETF holdings analysis, and zakat calculators. Free tier, no credit card.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://api.halalterminal.com" rel="noopener noreferrer"&gt;Get your free API key -&amp;gt;&lt;/a&gt; &lt;a href="https://www.halalterminal.com/product/api" rel="noopener noreferrer"&gt;Explore the API&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to go next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Official MCP registry:&lt;/strong&gt; find the server listed at &lt;a href="https://registry.modelcontextprotocol.io" rel="noopener noreferrer"&gt;registry.modelcontextprotocol.io&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub repo:&lt;/strong&gt; setup guides for every client, the full tool reference, and issue tracker at &lt;a href="https://github.com/goww7/halalterminal-mcp" rel="noopener noreferrer"&gt;github.com/goww7/halalterminal-mcp&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API docs:&lt;/strong&gt; the interactive reference lives at &lt;a href="https://api.halalterminal.com/api-reference" rel="noopener noreferrer"&gt;api.halalterminal.com/api-reference&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Five minutes in, your AI client speaks Shariah screening. Get your key at &lt;a href="https://api.halalterminal.com" rel="noopener noreferrer"&gt;api.halalterminal.com&lt;/a&gt; and ask it something.&lt;/p&gt;

&lt;h3&gt;
  
  
  Important Disclaimer
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Not financial advice.&lt;/strong&gt; The information provided on this page is for educational and informational purposes only and should not be construed as financial advice, investment advice, trading advice, or any other type of advice. You should not make any financial decisions based solely on the information presented here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not a fatwa.&lt;/strong&gt; Shariah compliance screening results are generated using automated data analysis based on publicly available financial data. These results do not constitute a religious ruling (fatwa) and should not be treated as one. Always consult a qualified Islamic scholar or Shariah advisor for guidance specific to your situation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do your own research.&lt;/strong&gt; Past performance and current compliance status do not guarantee future results or continued compliance. Screening data may contain errors or become outdated. Always verify information independently and consult with a qualified financial advisor before making any investment decisions.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://api.halalterminal.com/blog/posts/connect-claude-shariah-screening-mcp" rel="noopener noreferrer"&gt;Halal Terminal blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>claude</category>
      <category>ai</category>
      <category>finance</category>
    </item>
  </channel>
</rss>
