Quick Start
Quick Start
Section titled “Quick Start”Build a complete Islamic Open Finance™ integration in 15 minutes.
What We’ll Build
Section titled “What We’ll Build”In this quick start, you’ll:
- Create a sandbox account
- Install the SDK
- Create your first Murabaha contract
- Set up webhook notifications
- Query contract status
Prerequisites
Section titled “Prerequisites”- Node.js 18+ or Python 3.9+
- An IDE or text editor
- Basic REST API knowledge
Step 1: Get Your API Credentials
Section titled “Step 1: Get Your API Credentials”- Sign up at cloud.islamicopenfinance.com
- Navigate to Settings → API Keys
- Click Create API Key
- Name it “Quickstart Demo”
- Copy the key (you won’t see it again!)
# Set your API key as an environment variableexport IOF_API_KEY=sk_sandbox_your_key_hereStep 2: Install the SDK
Section titled “Step 2: Install the SDK”npm install @iof/sdkpnpm add @iof/sdkpip install iof-sdk:::
Step 3: Initialize the Client
Section titled “Step 3: Initialize the Client”Create a new file quickstart.ts (or quickstart.py):
import { IOFClient } from "@iof/sdk";
const client = new IOFClient({ apiKey: process.env.IOF_API_KEY!, environment: "sandbox",});
async function main() { // We'll add code here}
main().catch(console.error);import osfrom iof import IOFClient
client = IOFClient( api_key=os.environ["IOF_API_KEY"], environment="sandbox")
def main(): # We'll add code here pass
if __name__ == "__main__": main():::
Step 4: Create Entities
Section titled “Step 4: Create Entities”Before creating a contract, we need to create the parties:
// Create the financier (bank/institution)const financier = await client.entities.create({ type: "institution", name: "Al Rajhi Bank", jurisdiction: "SA", registrationNumber: "123456789",});
// Create the customerconst customer = await client.entities.create({ type: "individual", name: "Ahmed Al-Rashid", jurisdiction: "SA", nationalId: "1234567890", email: "ahmed@example.com",});
console.log("Financier:", financier.id);console.log("Customer:", customer.id);# Create the financier (bank/institution)financier = client.entities.create( type="institution", name="Al Rajhi Bank", jurisdiction="SA", registration_number="123456789")
# Create the customercustomer = client.entities.create( type="individual", name="Ahmed Al-Rashid", jurisdiction="SA", national_id="1234567890", email="ahmed@example.com")
print(f"Financier: {financier.id}")print(f"Customer: {customer.id}"):::
Step 5: Create a Murabaha Contract
Section titled “Step 5: Create a Murabaha Contract”Now let’s create a vehicle financing contract:
const contract = await client.contracts.create({ type: "murabaha", jurisdiction: "SA", parties: { financier: { entityId: financier.id }, customer: { entityId: customer.id }, }, asset: { description: "Toyota Land Cruiser 2024", category: "vehicle", vin: "JTDKN3DU5A0123456", costPrice: { amount: 250000, currency: "SAR", }, profitMargin: 0.07, // 7% profit margin }, terms: { paymentSchedule: "monthly", numberOfInstallments: 60, // 5 years gracePeriodDays: 30, lateFeePercentage: 0.02, },});
console.log("Contract created:", contract.id);console.log("Status:", contract.status);console.log("Monthly payment:", contract.payment.monthlyAmount, "SAR");console.log("Total amount:", contract.payment.totalAmount, "SAR");contract = client.contracts.create( type="murabaha", jurisdiction="SA", parties={ "financier": {"entity_id": financier.id}, "customer": {"entity_id": customer.id}, }, asset={ "description": "Toyota Land Cruiser 2024", "category": "vehicle", "vin": "JTDKN3DU5A0123456", "cost_price": { "amount": 250000, "currency": "SAR", }, "profit_margin": 0.07, # 7% profit margin }, terms={ "payment_schedule": "monthly", "number_of_installments": 60, # 5 years "grace_period_days": 30, "late_fee_percentage": 0.02, })
print(f"Contract created: {contract.id}")print(f"Status: {contract.status}")print(f"Monthly payment: {contract.payment.monthly_amount} SAR")print(f"Total amount: {contract.payment.total_amount} SAR"):::
Step 6: Submit for Shariah Review
Section titled “Step 6: Submit for Shariah Review”// Submit for Shariah compliance reviewconst submitted = await client.contracts.submit(contract.id);console.log("Contract submitted for review:", submitted.status);
// In sandbox, approval is automatic// In production, this would go through the Shariah board# Submit for Shariah compliance reviewsubmitted = client.contracts.submit(contract.id)print(f"Contract submitted for review: {submitted.status}")
# In sandbox, approval is automatic# In production, this would go through the Shariah board:::
Step 7: Set Up Webhooks
Section titled “Step 7: Set Up Webhooks”Create a webhook subscription to receive real-time updates:
const webhook = await client.webhooks.create({ url: "https://your-app.com/webhooks/iof", events: [ "contract.approved", "contract.activated", "payment.received", "payment.overdue", ], secret: process.env.WEBHOOK_SECRET,});
console.log("Webhook created:", webhook.id);webhook = client.webhooks.create( url="https://your-app.com/webhooks/iof", events=[ "contract.approved", "contract.activated", "payment.received", "payment.overdue", ], secret=os.environ["WEBHOOK_SECRET"])
print(f"Webhook created: {webhook.id}"):::
Step 8: Query Contract Status
Section titled “Step 8: Query Contract Status”// Get contract detailsconst details = await client.contracts.get(contract.id);console.log("Contract details:", details);
// List all contractsconst contracts = await client.contracts.list({ status: "active", type: "murabaha",});
for (const c of contracts.data) { console.log(`${c.id}: ${c.asset.description} - ${c.status}`);}# Get contract detailsdetails = client.contracts.get(contract.id)print(f"Contract details: {details}")
# List all contractscontracts = client.contracts.list( status="active", type="murabaha")
for c in contracts.data: print(f"{c.id}: {c.asset.description} - {c.status}"):::
Complete Example
Section titled “Complete Example”Here’s the complete quickstart script:
import { IOFClient } from "@iof/sdk";
const client = new IOFClient({ apiKey: process.env.IOF_API_KEY!, environment: "sandbox",});
async function main() { // 1. Create entities const financier = await client.entities.create({ type: "institution", name: "Al Rajhi Bank", jurisdiction: "SA", registrationNumber: "123456789", });
const customer = await client.entities.create({ type: "individual", name: "Ahmed Al-Rashid", jurisdiction: "SA", nationalId: "1234567890", });
// 2. Create contract const contract = await client.contracts.create({ type: "murabaha", jurisdiction: "SA", parties: { financier: { entityId: financier.id }, customer: { entityId: customer.id }, }, asset: { description: "Toyota Land Cruiser 2024", category: "vehicle", costPrice: { amount: 250000, currency: "SAR" }, profitMargin: 0.07, }, terms: { paymentSchedule: "monthly", numberOfInstallments: 60, }, });
console.log("Contract created:", contract.id); console.log("Monthly payment:", contract.payment.monthlyAmount, "SAR");
// 3. Submit for review await client.contracts.submit(contract.id); console.log("Contract submitted for Shariah review");
// 4. Set up webhook await client.webhooks.create({ url: "https://your-app.com/webhooks/iof", events: ["contract.approved", "payment.received"], });
console.log("Setup complete!");}
main().catch(console.error);:::
Next Steps
Section titled “Next Steps”Congratulations! You’ve created your first Islamic Open Finance™ contract.
- API Reference - Explore all available endpoints
- Webhooks Guide - Learn more about event notifications
- Contract Types - Explore all Shariah-compliant contract types
- SDKs - Detailed SDK documentation