تجاوز إلى المحتوى الرئيسي

How to Generate Arabic Images via API

A developer guide to generating personalized Arabic images with correct RTL, diacritics, and OpenType shaping using the Mirqam API — with cURL, Python, and Node.js examples.

Most image generation APIs break when you throw Arabic text at them. Diacritics end up in the wrong place, ligatures don't connect, and RTL layout is an afterthought. Mirqam is built Arabic-first — correct shaping, diacritics, and OpenType rendering out of the box.

This guide shows you how to generate personalized Arabic images via the Mirqam API.

Quick Start

1. Get an API Key

Sign up at mirqam.net/sign-up and create an API key from your dashboard. Keys start with ak_... and are passed as Bearer tokens.

You get 100 free credits on signup (1 credit = 5 API renders).

2. Create a Template

Open the template editor and design your card:

  1. Upload a background image
  2. Add dynamic text fields (name, title, date, etc.)
  3. Choose your Arabic fonts and adjust sizing
  4. Save — you'll get a template_id

3. Render via API

Send a POST request with your template ID and data:

cURL:

bash
curl -X POST https://app.mirqam.net/v1/render \
  -H "Authorization: Bearer ak_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "template_id": "tpl_abc123",
    "data": {
      "name": "عبدالرحمٰن"
    },
    "options": {
      "format": "png"
    }
  }'

Python:

python
import requests

response = requests.post(
    "https://app.mirqam.net/v1/render",
    headers={"Authorization": "Bearer ak_your_key_here"},
    json={
        "template_id": "tpl_abc123",
        "data": {"name": "عبدالرحمٰن"},
        "options": {"format": "png"},
    },
)

with open("card.png", "wb") as f:
    f.write(response.content)

Node.js:

javascript
const response = await fetch("https://app.mirqam.net/v1/render", {
  method: "POST",
  headers: {
    "Authorization": "Bearer ak_your_key_here",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    template_id: "tpl_abc123",
    data: { name: "عبدالرحمٰن" },
    options: { format: "png" },
  }),
});

const buffer = await response.arrayBuffer();
fs.writeFileSync("card.png", Buffer.from(buffer));

The response is the raw image bytes — PNG or JPG, depending on your options.format.

Why Not Use Generic Image APIs?

If you've tried generating Arabic text images with Puppeteer, wkhtmltoimage, or Cloudinary, you've probably hit these problems:

Puppeteer / HTML Screenshots

  • Diacritics (tashkeel) often render in the wrong position
  • Font fallback chains produce inconsistent results
  • Headless Chrome adds overhead and non-determinism
  • Memory-hungry for batch processing

Cloudinary Text Overlays

  • Limited Arabic font support
  • No OpenType shaping for complex ligatures
  • Diacritics positioning is unreliable
  • No RTL-aware text wrapping

Mirqam's Approach

  • Server-side raster rendering — no browser, no DOM
  • Arabic-first shaping engine — correct ligatures, diacritics, and RTL
  • Deterministic output — same input always produces the same image
  • Fast — ~1 second per render
  • Custom fonts — upload any TTF/OTF font

Key API Features

FeatureDetails
FormatsPNG, JPG (optionally wrapped in PDF)
AuthenticationBearer token (ak_...)
Dynamic fieldsText and image fields per template
DiacriticsFull tashkeel support (fatha, kasra, shadda, etc.)
Custom fontsUpload TTF/OTF via /v1/fonts
Batch processingLoop over names — each render is independent
DeterministicSame data = same output, every time

Pricing

  • 0.2 SAR per image via API (~$0.05 USD)
  • 100 free credits on signup (= 500 API renders)
  • No subscriptions, no monthly fees
  • Pay as you go

See full pricing

Common Use Cases

  • HR campaigns: Generate Eid greeting cards for 500+ employees
  • E-commerce: Auto-generate thank-you cards with customer names (Salla integration)
  • Certificates: Course completion or appreciation certificates
  • Invitations: Wedding or event invitations personalized by name
  • Marketing: Personalized social media images at scale

Next Steps

  1. Sign up for free — 100 credits included
  2. Read the API docs — full endpoint reference
  3. Try the render playground — test renders in-browser
  4. Browse AI prompts — prompt templates for LLM integration

Need help integrating? Contact our team for developer support.

How to Generate Arabic Images via API | مِرقم