Quick Start
Build a complete Islamic Open Finance™ integration in 15 minutes.
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
- Node.js 18+ or Python 3.9+
- An IDE or text editor
- Basic REST API knowledge
Step 1: Get Your API Credentials
- Sign up at app.islamicopenfinance.com
- Navigate to Settings → API Keys
- Click Create API Key
- Name it "Quickstart Demo"
- Copy the key (you won't see it again!)
bash
# Set your API key as an environment variable
export IOF_API_KEY=sk_sandbox_your_key_hereStep 2: Install the SDK
bash
npm install @iof/sdkbash
pnpm add @iof/sdkbash
pip install iof-sdkStep 3: Initialize the Client
Create a new file quickstart.ts (or quickstart.py):
typescript
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);python
import os
from 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
Before creating a contract, we need to create the parties:
typescript
// Create the financier (bank/institution)
const financier = await client.entities.create({
type: "institution",
name: "Al Rajhi Bank",
jurisdiction: "SA",
registrationNumber: "123456789",
});
// Create the customer
const 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);python
# Create the financier (bank/institution)
financier = client.entities.create(
type="institution",
name="Al Rajhi Bank",
jurisdiction="SA",
registration_number="123456789"
)
# Create the customer
customer = 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
Now let's create a vehicle financing contract:
typescript
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");python
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
typescript
// Submit for Shariah compliance review
const 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 boardpython
# Submit for Shariah compliance review
submitted = 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 boardStep 7: Set Up Webhooks
Create a webhook subscription to receive real-time updates:
typescript
const webhook = await client.webhooks.create({
url: "https://your-app.com/webhooks/iof",
events: [
"contract.approved",
"contract.activated",
"payment.received",
"payment.overdue",
],
secret: "whsec_your_webhook_secret",
});
console.log("Webhook created:", webhook.id);python
webhook = client.webhooks.create(
url="https://your-app.com/webhooks/iof",
events=[
"contract.approved",
"contract.activated",
"payment.received",
"payment.overdue",
],
secret="whsec_your_webhook_secret"
)
print(f"Webhook created: {webhook.id}")Step 8: Query Contract Status
typescript
// Get contract details
const details = await client.contracts.get(contract.id);
console.log("Contract details:", details);
// List all contracts
const contracts = await client.contracts.list({
status: "active",
type: "murabaha",
});
for (const c of contracts.data) {
console.log(`${c.id}: ${c.asset.description} - ${c.status}`);
}python
# Get contract details
details = client.contracts.get(contract.id)
print(f"Contract details: {details}")
# List all contracts
contracts = client.contracts.list(
status="active",
type="murabaha"
)
for c in contracts.data:
print(f"{c.id}: {c.asset.description} - {c.status}")Complete Example
Here's the complete quickstart script:
typescript
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
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