PicDP

API Documentation

The PicDP API creates diamond painting previews and size recommendations for your online store. Upload a photo, receive a realistic preview, and let customers select the right size.

Base URL

https://diamondpaintingconverter.com/api/v1

Format

JSON + multipart/form-data

Version

v1 (stable)

Rollout checklist for platform integrations

Script-tag widget

Select a Browser widget key in the dashboard and enter the exact store origin. Add these two lines to the product page; no custom backend is required.

<diamond-painting-preview key="dp_embed_JOUW_KEY" lang="nl"></diamond-painting-preview>
<script async src="https://diamondpaintingconverter.com/static/js/dp-preview.js"></script>

After a successful request, the widget dispatches the dp-preview:completed browser event. The payload in event.detail contains the job, preview URL, and size recommendation for your add-to-cart code. Never include a dp_live_ server key in browser code.

WooCommerce plugin

For WooCommerce stores, the free plugin adds photo upload, size selection (with surcharges), drill selection, and the live preview as a complete order flow on the product page. The customer photo, size, and preview link are automatically added to the order and order emails as order metadata.

Download dp-preview-for-woocommerce.zip

Installation: upload via Plugins → Add New → Upload Plugin, activate it, and enter your widget key under Settings → DP Preview.

Free up to 50 previews per day · Starter €19/month (500/day) · Pro €49/month (2500/day) — manage your subscription in the dashboard.

Authentication

Server integrations require a Bearer token in the Authorization header. The browser widget uses a separate domain-bound embed key.

Authorization: Bearer dp_live_xxxxxxxxxxxxxxxx

Contact the PicDP team to request an API key. The key is displayed once when created — store it securely. Authentication errors (401) may use the default DRF error format in the response body.

WooCommerce quickstart

Start from a WordPress plugin or mu-plugin. Send the upload with wait=5, fall back to polling after a 202 Accepted response, and store the job_id and variant mapping in the cart item metadata.

  • Use Authorization: Bearer dp_live_... and a unique Idempotency-Key for each cart item.
  • Send product context through external_product_id, partner_context, and optionally allowed_sizes.

Go to WooCommerce integration

Shopify quickstart

Use an app backend (Node/TypeScript) as an adapter. Make an initial request with wait=5, fall back to polling /api/v1/jobs/{job_id}, and store preview metadata in line item properties.

  • Keep pricing and inventory in Shopify; use the API output only for the preview and size recommendation.
  • Verify webhook signatures with your shared secret before triggering order or fulfillment flows.

Go to Shopify integration

Request preview

POST /api/v1/preview

Upload a photo and receive a diamond painting preview with size recommendations. Use ?wait=5 to wait up to 5 seconds for the result.

# Voorbeeld request
curl -X POST "https://diamondpaintingconverter.com/api/v1/preview?wait=5" \
  -H "Authorization: Bearer dp_live_JOUW_KEY" \
  -F "file=@foto.jpg" \
  -F "target_width_cm=40"

Response (200 OK)

{
  "request_id": "req_abc123...",
  "job": {
    "id": "550e8400-e29b-...",
    "type": "single",
    "status": "completed"
  },
  "result": {
    "preview_url": "https://diamondpaintingconverter.com/media/api/previews/550e84...png",
    "recommendations": {
      "style_mode": "balanced",
      "drill_type": "square_2_5mm",
      "recommended": { "size": [40, 22], "quality_score": 82 },
      "minimum": { "size": [20, 11], "quality_score": 91 },
      "top_formats": [ ... ],
      "quality_threshold": 55
    }
  },
  "error": null
}

Parameters

Parameter Type Default Description
file file required JPEG, PNG, or WebP (max 20 MB)
target_width_cm integer 40 Target width in centimeters
quality_mode string balanced speed, balanced, or detail
drill_type string square_2_5mm square_2_5mm or round_2_8mm
auto_crop boolean false Automatically crop to the optimal aspect ratio

Async processing & polling

Without ?wait=N, the API usually returns 202 Accepted. For an idempotent retry or an already completed job, the same request may return 200 OK. Then poll the job status:

# 1. Start preview (krijg job ID terug)
curl -X POST "https://diamondpaintingconverter.com/api/v1/preview" \
  -H "Authorization: Bearer dp_live_JOUW_KEY" \
  -F "file=@foto.jpg" \
  -F "target_width_cm=40"

# 2. Poll de status
curl "https://diamondpaintingconverter.com/api/v1/jobs/{job_id}" \
  -H "Authorization: Bearer dp_live_JOUW_KEY"

Job statuses

GET /api/v1/jobs/{job_id}

pending → processing → completed

For processing errors, polling returns an error envelope with HTTP 500 and job: null.

Batch preview

POST /api/v1/batch-preview

Group previously created single previews into a batch. A batch can contain up to 50 items.

curl -X POST "https://diamondpaintingconverter.com/api/v1/batch-preview" \
  -H "Authorization: Bearer dp_live_JOUW_KEY" \
  -H "Content-Type: application/json" \
  -d '{"job_ids": ["job-id-1", "job-id-2", "job-id-3"]}'

Retrieve items with cursor pagination:

GET /api/v1/jobs/{batch_id}/items?cursor=0

{
  "result": {
    "items": [
      { "index": 0, "status": "completed", "preview_url": "..." },
      { "index": 1, "status": "completed", "preview_url": "..." }
    ],
    "next_cursor": null
  }
}

Webhooks

Receive a notification when a job completes or fails. Configure webhooks in the dashboard under Dashboard → Webhooks.

Create an API key, add a webhook URL and events, then provide a secret or generate one automatically. Each webhook is linked to one API key and must use a publicly accessible URL (localhost and private networks are blocked).

Events

job.completed job.failed

Payload example

{
  "event": "job.completed",
  "job_id": "550e8400-...",
  "job_type": "single",
  "status": "completed",
  "result": { ... },
  "error": null
}

For job.failed, error contains an object with code and message.

Signature verification

Each webhook includes HMAC-SHA256 headers. Verify the signature with your webhook secret:

X-Webhook-Id X-Webhook-Timestamp X-Signature: sha256=...
# Python verificatie (gebruik raw request body bytes)
import hashlib, hmac

webhook_id = headers["X-Webhook-Id"]
timestamp = headers["X-Webhook-Timestamp"]
signature = headers["X-Signature"].split("sha256=", 1)[1]

sign_payload = f"{webhook_id}.{timestamp}.".encode() + raw_body_bytes
expected = hmac.new(YOUR_SECRET.encode(), sign_payload, hashlib.sha256).hexdigest()

assert hmac.compare_digest(signature, expected)

Delivery is at-least-once: requests are retried after network errors or 5xx responses. Use X-Webhook-Id for idempotent processing and to ignore duplicates.

Idempotency

Prevent duplicate processing by sending an Idempotency-Key header. The same key with the same parameters returns the original job.

curl -X POST "https://diamondpaintingconverter.com/api/v1/preview?wait=5" \
  -H "Authorization: Bearer dp_live_JOUW_KEY" \
  -H "Idempotency-Key: order-12345-preview" \
  -F "file=@foto.jpg"

Note: The same idempotency key with different parameters returns 409 Conflict. Keys expire automatically after 24 hours.

Rate limits

60

Rate-limit units per minute

1.000

Rate-limit units per day

Preview requests use weighted units: 1 + ceil(min(allowed_sizes, 50) / 10).

When exceeded, the API returns 429 Too Many Requests with Retry-After, and, for POST /api/v1/preview, also X-RateLimit-Used-Units, X-RateLimit-Remaining, X-RateLimit-Reset.

Upload limits

Check Limit Response
File size20 MB422
File typeJPEG, PNG, WebP422
Items per batch50400
Wait parametermax 10 sec—

Rollout checklist

Use this checklist for every production release of WooCommerce and Shopify integrations.

  • Check the web, worker, and beat processes, plus Redis connectivity.
  • Validate webhook signatures and duplicate handling with a test endpoint.
  • Confirm absolute preview URLs and rate-limit headers (X-RateLimit-Used-Units, X-RateLimit-Remaining, X-RateLimit-Reset).

Error codes

API errors usually use an error object with code and message. Authentication errors (401) may return the default DRF error output.

HTTP Error code Cause
400missing_fileNo file provided
400/422invalid_parameterInvalid parameter (type, range, or allowed_sizes payload)
400invalid_payloadInvalid JSON body
401—Invalid or missing API key
409idempotency_conflictIdempotency key reused with different parameters
422invalid_mimeUnsupported file type
422file_too_largeFile larger than 20 MB
429rate_limit_exceededRate limit exceeded
500processing_errorProcessing error
503api_disabledAPI temporarily disabled