Dike logoDocs

This guide gets you up and running with the Dike API across three environments: cURL, Python, and TypeScript (Node.js).


1. Create an API Key

  1. Navigate to the Dike Developer Dashboard.
  2. Go to API Credentials and copy your live key (prefixed with dike_live_).
  3. Store the key in your local environment:
export DIKE_API_KEY="dike_live_your_actual_key_here"

Let's search for carrier liability in Egyptian commercial law:

curl -X POST https://api.dike.it.com/v1/search \
  -H "Authorization: Bearer $DIKE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "مسؤولية الناقل الجوي عن تأخير الرحلات وتلف الأمتعة",
    "top_k": 3,
    "filters": {
      "jurisdiction": "EG",
      "status": ["in_force"]
    },
    "rerank": true
  }'
import os
import httpx

api_key = os.environ.get("DIKE_API_KEY")

response = httpx.post(
    "https://api.dike.it.com/v1/search",
    headers={
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json",
    },
    json={
        "query": "مسؤولية الناقل الجوي عن تأخير الرحلات وتلف الأمتعة",
        "top_k": 3,
        "filters": {
            "jurisdiction": "EG",
            "status": ["in_force"]
        },
        "rerank": True,
    },
    timeout=10.0,
)

data = response.json()
for result in data.get("results", []):
    print(f"[{result['canonical_id']}] {result['title']} (Article {result.get('article_no', 'N/A')})")
    print(f"Score: {result['score']:.3f} | Citation: {result.get('citation_string')}\n")
const apiKey = process.env.DIKE_API_KEY;

async function runSearch() {
  const response = await fetch('https://api.dike.it.com/v1/search', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${apiKey}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      query: 'مسؤولية الناقل الجوي عن تأخير الرحلات وتلف الأمتعة',
      top_k: 3,
      filters: {
        jurisdiction: 'EG',
        status: ['in_force'],
      },
      rerank: true,
    }),
  });

  const data = await response.json();
  console.log(`Found ${data.results.length} matches in ${data.took_ms}ms:`);
  
  for (const item of data.results) {
    console.log(`• [${item.canonical_id}] ${item.title} - Art. ${item.article_no}`);
  }
}

runSearch();

Expected Search Response

{
  "results": [
    {
      "canonical_id": "eg-leg-1999-17",
      "score": 0.942,
      "doc_type": "legislation",
      "title": "قانون التجارة رقم 17 لسنة 1999",
      "article_no": "217",
      "snippet": "يسأل الناقل الجوي عن الضرر الذي ينشأ عن هلاك الأمتعة أو تلفها أو تأخر وصولها...",
      "year": 1999,
      "status": "in_force",
      "citation_string": "المادة 217 من قانون التجارة رقم 17 لسنة 1999"
    }
  ],
  "took_ms": 118,
  "fusion": "rrf",
  "reranked": true
}

Now, let's ask a complex question that requires synthesizing legal articles with verified citations:

curl -X POST https://api.dike.it.com/v1/reason \
  -H "Authorization: Bearer $DIKE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "question": "ما هي التزامات المؤجر في صيانة العين المؤجرة وفقاً للقانون المصري؟",
    "filters": {
      "jurisdiction": "EG"
    },
    "language": "ar"
  }'
import os
import httpx

api_key = os.environ.get("DIKE_API_KEY")

response = httpx.post(
    "https://api.dike.it.com/v1/reason",
    headers={
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json",
    },
    json={
        "question": "ما هي التزامات المؤجر في صيانة العين المؤجرة وفقاً للقانون المصري؟",
        "filters": {"jurisdiction": "EG"},
        "language": "ar",
    },
    timeout=30.0,
)

data = response.json()
print("Answer:\n", data["answer"])
print("\nVerified Citations:")
for cite in data.get("citations", []):
    print(f"[{cite['marker']}] {cite['citation_string']} (ID: {cite['canonical_id']})")
const apiKey = process.env.DIKE_API_KEY;

async function askReason() {
  const response = await fetch('https://api.dike.it.com/v1/reason', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${apiKey}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      question: 'ما هي التزامات المؤجر في صيانة العين المؤجرة وفقاً للقانون المصري؟',
      filters: { jurisdiction: 'EG' },
      language: 'ar',
    }),
  });

  const data = await response.json();
  console.log('Answer:\n', data.answer);
  console.log('\nVerified Citations:', data.citations);
}

askReason();

Expected Reason Response

{
  "answer": "يلتزم المؤجر بتسليم العين المؤجرة في حالة تصلح معها للاستيفاء المقصود منها [1]، كما يلتزم بالقيام بجميع الترميمات الضرورية لحفظ العين أثناء مدة الإيجار [2]. وإذا أخل المؤجر بتنفيذ هذه الالتزامات بعد إعذاره، جاز للمستأجر أن يحصل على ترخيص من القضاء بإجراء الصيانة على نفقة المؤجر [2].",
  "citations": [
    {
      "marker": 1,
      "canonical_id": "eg-leg-1948-131",
      "article_no": "564",
      "citation_string": "المادة 564 من القانون المدني رقم 131 لسنة 1948",
      "snippet": "يلتزم المؤجر أن يسلم المستأجر العين المؤجرة وملحقاتها في حالة تصلح معها لأن تفي بما أعدت له من المنفعة...",
      "verified": true
    },
    {
      "marker": 2,
      "canonical_id": "eg-leg-1948-131",
      "article_no": "567",
      "citation_string": "المادة 567 من القانون المدني رقم 131 لسنة 1948",
      "snippet": "على المؤجر أن يتعهد العين المؤجرة بالصيانة لتبقى على الحالة التي سلمت بها وأن يقوم بالترميمات الضرورية...",
      "verified": true
    }
  ],
  "grounding": {
    "retrieved": 12,
    "used": 2,
    "dropped_unverified_refs": 0
  },
  "took_ms": 2840
}

4. Next Steps

On this page