Developer & APIPartner api
Examples
Reference snippets for estimates, RFQs, and webhook verification with the Partner API.
Entwicklerdocs2 Min. LesezeitGeprüft 16. Apr. 2026
Examples
Use these snippets as starting points, but always validate payloads and response handling against
the published contract at /docs/api/openapi.yaml.
cURL: request an estimate
curl -X POST https://api.nowtoprint.com/api/v1/estimate \
-H "Authorization: Bearer ntp_test_your_key" \
-H "Content-Type: application/json" \
-d '{
"category": "brochure",
"quantity": 500,
"specifications": {
"pageCount": 16
}
}'
Node.js: create an RFQ
const response = await fetch('https://api.nowtoprint.com/api/v1/rfq', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.NOWTOPRINT_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify({
title: 'Spring brochure batch',
category: 'brochure',
quantity: 2500,
deliveryCity: 'Istanbul',
}),
});
if (!response.ok) {
throw new Error(`RFQ creation failed: ${response.status}`);
}
const rfq = await response.json();
console.log(rfq.id);
Python: poll RFQ status
import os
import requests
headers = {
"Authorization": f"Bearer {os.environ['NOWTOPRINT_API_KEY']}",
"Accept": "application/json",
}
response = requests.get(
"https://api.nowtoprint.com/api/v1/rfq/rfq_123456",
headers=headers,
timeout=30,
)
response.raise_for_status()
print(response.json())
Node.js: verify webhook signatures
import crypto from 'node:crypto';
export function verifyWebhookSignature(payload: string, signature: string, secret: string) {
const digest = crypto.createHmac('sha256', secret).update(payload).digest('hex');
return signature === `sha256=${digest}`;
}
Use the raw request body for verification before parsing JSON.
Production notes
- keep keys and webhook secrets in managed server-side secrets
- do not trust client-side integrations with direct live credentials
- log request IDs, not credentials
- treat webhook consumers as idempotent workers
War dieser Artikel hilfreich?
Verwandte Artikel
Edit on GitHub
Zuletzt aktualisiert