Skip to content

Instantly share code, notes, and snippets.

@illbzo1
illbzo1 / doc_raptor_async_example.sh
Last active August 29, 2015 14:18
Asynchronous Curl example for DocRaptor
#This example will create a sample asynchronous pdf document with the authentication information as part of the POST data
curl -H "Content-Type:application/json" -d'{"user_credentials":"YOUR_API_KEY_HERE", "doc":{"name":"async_example.pdf", "document_type":"pdf", "async":"true", "test":"true", "document_url":"https://docraptor.com"}}' http://docraptor.com/docs > async_example.pdf
#Making an asynchronous request will return some JSON with a status_id key like '{"status_id":"123454321"}'
cat async_example.pdf
#You can then use the status_id key to check the status of your asynchronous job
curl http://docraptor.com/status/123454321 -H "Content-Type:application/json" -d '{"user_credentials":"YOUR_API_KEY_HERE"}'
#Once your job has completed, you will recieve a response that contains the download_url for your document
@illbzo1
illbzo1 / node_request_example.js
Last active August 29, 2015 14:22
An example for making POST requests to DocRaptor in Node.js, using request instead of restler
var request = require('request');
var fs = require('fs');
var content = "<html><body>TEST!</body></html>";
config = {
url: 'https://docraptor.com/docs',
encoding: null, //IMPORTANT! This produces a binary body response instead of text
headers: {
'Content-Type': 'application/json'
},
@illbzo1
illbzo1 / nodejs_example.js
Created June 9, 2015 18:54
An example Node.js implementation for DocRaptor, that does not rely on any external dependencies.
var https = require("https"),
fs = require("fs");
var payload = JSON.stringify({
user_credentials: "YOUR_API_KEY_HERE",
doc: {
document_content: "<!DOCTYPE html><html><head><title>Javascript PDF Sample</title></head><body>Hello from Javascript!</body></html>",
name: "test.pdf",
document_type: "pdf",
test: true

Keybase proof

I hereby claim:

To claim this, I am signing this object: