// This code requires Node.js. Do not run this code directly in a web browser.const axios =require('axios')const FormData =require('form-data')const fs =require('fs')const body =JSON.stringify({parts:[{file:{url:"https://www.nutrient.io/api/assets/downloads/samples/docx/document.docx"}}]});(async()=>{try{const response =await axios.post('https://api.nutrient.io/build', body,{headers:{'Content-Type':'application/json','Authorization':'Bearer your_api_key_here'},responseType:"stream"})
response.data.pipe(fs.createWriteStream("result.pdf"))}catch(e){const errorString =awaitstreamToString(e.response.data)
console.log(errorString)}})()functionstreamToString(stream){const chunks =[]returnnewPromise((resolve, reject)=>{
stream.on("data",(chunk)=> chunks.push(Buffer.from(chunk)))
stream.on("error",(err)=>reject(err))
stream.on("end",()=>resolve(Buffer.concat(chunks).toString("utf8")))})}
import requests
import json
body = json.dumps({'parts':[{'file':{'url':'https://www.nutrient.io/api/assets/downloads/samples/docx/document.docx'}}]})
response = requests.request('POST','https://api.nutrient.io/build',
headers ={'Content-Type':'application/json','Authorization':'Bearer your_api_key_here'},
data = body,
stream =True)if response.ok:withopen('result.pdf','wb')as fd:for chunk in response.iter_content(chunk_size=8096):
fd.write(chunk)else:print(response.text)
exit()
No input or resulting documents are stored on our infrastructure. All files are deleted as soon as a request finishes. Alternatively,
check out
our self-hosted product.
HTTPS encryption
All communication between your application and Nutrient is done via HTTPS to ensure your data is encrypted when it’s sent to us.
Safe payment processing
All payments are handled by Paddle. Nutrient DWS Processor API never has direct access to any of your payment data.
Ready to try it?
Create an account to get your API key and start making API calls.