דלג לתוכן
API v1

תיעוד API

השתמש ב-DishPic API כדי לשלב המרת תמונות מזון מקצועיות ישירות לאפליקציה שלך. כל הבקשות דורשות API Key שניתן ליצור בדף ההגדרות.

אימות

כל הבקשות ל-API דורשות header של Authorization עם ה-API Key שלך:

http
Authorization: Bearer dp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ניתן ליצור API Key חדש בדף ההגדרות. המפתח מוצג פעם אחת בלבד — שמור אותו במקום בטוח.
POST/api/generate

ממיר תמונת מנה למקצועית. דורש קרדיט אחד לכל תמונה שנוצרת.

פרמטרים (JSON body)

שדהסוגתיאור
dishImageBase64*stringתמונת המנה בקידוד Base64 (JPEG/PNG)
presetId*stringסגנון הצילום: "studio", "natural", "dark", "bright", "minimal" או ID של פריסט מותאם
categorystringקטגוריית המנה: "main", "salad", "dessert", "drink", "starter"

תגובה

json
{
  "imageBase64": "iVBORw0KGgoAAAANSUhEUgA...",
  "projectId": "550e8400-e29b-41d4-a716-446655440000",
  "creditsRemaining": 42
}

דוגמת cURL

curl
curl -X POST https://dishpic.co.il/api/generate \
  -H "Authorization: Bearer dp_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "dishImageBase64": "/9j/4AAQSkZJRg...",
    "presetId": "studio",
    "category": "main"
  }'
GET/api/custom-presets

מחזיר את כל הפריסטים המותאמים אישית שהעלית.

json
{
  "presets": [
    {
      "id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
      "name": "סגנון הבית",
      "referenceImageUrl": "https://kykwilrygdatujudlmew.supabase.co/...",
      "createdAt": "2026-04-01T08:00:00Z"
    }
  ]
}

Rate Limits

60

בקשות לדקה

לכל API Key

500

יצירת תמונות ליום

לחשבון

10MB

גודל תמונה מקסימלי

לבקשה

חריגה מהמגבלות תחזיר קוד שגיאה 429 Too Many Requests.

קודי שגיאה

קוד HTTPשגיאהתיאור
400Bad Requestפרמטר חסר או לא תקין
401UnauthorizedAPI Key חסר או לא תקין
402Payment Requiredאין מספיק קרדיטים בחשבון
429Too Many Requestsחרגת ממגבלת הבקשות
500Internal Server Errorשגיאת שרת — נסה שוב
json
// פורמט תגובת שגיאה
{
  "error": "תיאור השגיאה כאן"
}

דוגמאות קוד

TypeScript / Node.js

typescript
import fs from "fs";

const API_KEY = process.env.DISHPIC_API_KEY!;
const API_URL = "https://dishpic.co.il";

async function generateDishPhoto(imagePath: string) {
  // Read image and convert to base64
  const imageBuffer = fs.readFileSync(imagePath);
  const imageBase64 = imageBuffer.toString("base64");

  const response = await fetch(`${API_URL}/api/generate`, {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      dishImageBase64: imageBase64,
      presetId: "studio",
      category: "main",
    }),
  });

  if (!response.ok) {
    const error = await response.json();
    throw new Error(error.error);
  }

  const { imageBase64: resultBase64, creditsRemaining } = await response.json();
  console.log(`Credits remaining: ${creditsRemaining}`);

  // Save result
  const resultBuffer = Buffer.from(resultBase64, "base64");
  fs.writeFileSync("result.jpg", resultBuffer);
  console.log("Saved to result.jpg");
}

generateDishPhoto("./dish.jpg").catch(console.error);

Python

python
import base64
import requests

API_KEY = "dp_your_api_key_here"
API_URL = "https://dishpic.co.il"

def generate_dish_photo(image_path: str) -> bytes:
    with open(image_path, "rb") as f:
        image_base64 = base64.b64encode(f.read()).decode("utf-8")

    response = requests.post(
        f"{API_URL}/api/generate",
        headers={
            "Authorization": f"Bearer {API_KEY}",
            "Content-Type": "application/json",
        },
        json={
            "dishImageBase64": image_base64,
            "presetId": "studio",
            "category": "main",
        },
    )
    response.raise_for_status()
    data = response.json()

    print(f"Credits remaining: {data['creditsRemaining']}")
    return base64.b64decode(data["imageBase64"])

result = generate_dish_photo("dish.jpg")
with open("result.jpg", "wb") as f:
    f.write(result)
print("Saved to result.jpg")

מוכן להתחיל?

צור API Key בדף ההגדרות והתחל לשלב DishPic באפליקציה שלך

צור API Key עכשיו ←