diff --git a/Python/raw JSON calls/README.md b/Python/raw JSON calls/README.md
new file mode 100644
index 0000000..914a5af
--- /dev/null
+++ b/Python/raw JSON calls/README.md
@@ -0,0 +1,10 @@
+This directory contains examples of how to call each endpoint of the
+PdfRest API using Python. Please refer to https://pdfrest.com/documentation.html
+for accepted inputs, options, and other specifics about individual endpoints.
+
+#### How to run Python samples
+
+Using Python3:
+
+1. `cd Python/`
+2. `python name-of-sample-program.py`
diff --git a/Python/raw JSON calls/bmp.py b/Python/raw JSON calls/bmp.py
new file mode 100644
index 0000000..9d66ad7
--- /dev/null
+++ b/Python/raw JSON calls/bmp.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ bmp_data = { "id" : uploaded_id }
+ print(json.dumps(bmp_data, indent = 2))
+
+
+ print("Processing file...")
+ bmp_response = requests.post(url='https://api.pdfrest.com/bmp',
+ data=json.dumps(bmp_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(bmp_response.status_code))
+ if bmp_response.ok:
+ bmp_response_json = bmp_response.json()
+ print(json.dumps(bmp_response_json, indent = 2))
+
+ else:
+ print(bmp_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/compressed-pdf.py b/Python/raw JSON calls/compressed-pdf.py
new file mode 100644
index 0000000..829022b
--- /dev/null
+++ b/Python/raw JSON calls/compressed-pdf.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ compress_data = { "id" : uploaded_id, "compression_level" : "low" }
+ print(json.dumps(compress_data, indent = 2))
+
+
+ print("Processing file...")
+ compress_response = requests.post(url='https://api.pdfrest.com/compressed-pdf',
+ data=json.dumps(compress_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(compress_response.status_code))
+ if compress_response.ok:
+ compress_response_json = compress_response.json()
+ print(json.dumps(compress_response_json, indent = 2))
+
+ else:
+ print(compress_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/decrypted-pdf.py b/Python/raw JSON calls/decrypted-pdf.py
new file mode 100644
index 0000000..71bc702
--- /dev/null
+++ b/Python/raw JSON calls/decrypted-pdf.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ decrypt_data = { "id" : uploaded_id, 'current_open_password': 'password' }
+ print(json.dumps(decrypt_data, indent = 2))
+
+
+ print("Processing file...")
+ decrypt_response = requests.post(url='https://api.pdfrest.com/decrypted-pdf',
+ data=json.dumps(decrypt_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(decrypt_response.status_code))
+ if decrypt_response.ok:
+ decrypt_response_json = decrypt_response.json()
+ print(json.dumps(decrypt_response_json, indent = 2))
+
+ else:
+ print(decrypt_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/encrypted-pdf.py b/Python/raw JSON calls/encrypted-pdf.py
new file mode 100644
index 0000000..d5c1685
--- /dev/null
+++ b/Python/raw JSON calls/encrypted-pdf.py
@@ -0,0 +1,38 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ encrypt_data = { "id" : uploaded_id, 'new_open_password': 'password' }
+ print(json.dumps(encrypt_data, indent = 2))
+
+ print("Processing file...")
+ encrypt_response = requests.post(url='https://api.pdfrest.com/encrypted-pdf',
+ data=json.dumps(encrypt_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(encrypt_response.status_code))
+ if encrypt_response.ok:
+ encrypt_response_json = encrypt_response.json()
+ print(json.dumps(encrypt_response_json, indent = 2))
+
+ else:
+ print(encrypt_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/exported-form-data.py b/Python/raw JSON calls/exported-form-data.py
new file mode 100644
index 0000000..3eba8e5
--- /dev/null
+++ b/Python/raw JSON calls/exported-form-data.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ export_data = { "id" : uploaded_id, 'data_format': 'xml' }
+ print(json.dumps(export_data, indent = 2))
+
+
+ print("Processing file...")
+ export_response = requests.post(url='https://api.pdfrest.com/exported-form-data',
+ data=json.dumps(export_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(export_response.status_code))
+ if export_response.ok:
+ export_response_json = export_response.json()
+ print(json.dumps(export_response_json, indent = 2))
+
+ else:
+ print(export_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/extracted-text.py b/Python/raw JSON calls/extracted-text.py
new file mode 100644
index 0000000..e88ea46
--- /dev/null
+++ b/Python/raw JSON calls/extracted-text.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ extract_data = { "id" : uploaded_id }
+ print(json.dumps(extract_data, indent = 2))
+
+
+ print("Processing file...")
+ extract_response = requests.post(url='https://api.pdfrest.com/extracted-text',
+ data=json.dumps(extract_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(extract_response.status_code))
+ if extract_response.ok:
+ extract_response_json = extract_response.json()
+ print(json.dumps(extract_response_json, indent = 2))
+
+ else:
+ print(extract_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/flattened-annotations-pdf.py b/Python/raw JSON calls/flattened-annotations-pdf.py
new file mode 100644
index 0000000..8953cb0
--- /dev/null
+++ b/Python/raw JSON calls/flattened-annotations-pdf.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ flatten_data = { "id" : uploaded_id }
+ print(json.dumps(flatten_data, indent = 2))
+
+
+ print("Processing file...")
+ flatten_response = requests.post(url='https://api.pdfrest.com/flattened-annotations-pdf',
+ data=json.dumps(flatten_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(flatten_response.status_code))
+ if flatten_response.ok:
+ flatten_response_json = flatten_response.json()
+ print(json.dumps(flatten_response_json, indent = 2))
+
+ else:
+ print(flatten_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/flattened-forms-pdf.py b/Python/raw JSON calls/flattened-forms-pdf.py
new file mode 100644
index 0000000..a14f285
--- /dev/null
+++ b/Python/raw JSON calls/flattened-forms-pdf.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ flatten_data = { "id" : uploaded_id }
+ print(json.dumps(flatten_data, indent = 2))
+
+
+ print("Processing file...")
+ flatten_response = requests.post(url='https://api.pdfrest.com/flattened-forms-pdf',
+ data=json.dumps(flatten_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(flatten_response.status_code))
+ if flatten_response.ok:
+ flatten_response_json = flatten_response.json()
+ print(json.dumps(flatten_response_json, indent = 2))
+
+ else:
+ print(flatten_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/flattened-layers-pdf.py b/Python/raw JSON calls/flattened-layers-pdf.py
new file mode 100644
index 0000000..a04f907
--- /dev/null
+++ b/Python/raw JSON calls/flattened-layers-pdf.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ flatten_data = { "id" : uploaded_id }
+ print(json.dumps(flatten_data, indent = 2))
+
+
+ print("Processing file...")
+ flatten_response = requests.post(url='https://api.pdfrest.com/flattened-layers-pdf',
+ data=json.dumps(flatten_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(flatten_response.status_code))
+ if flatten_response.ok:
+ flatten_response_json = flatten_response.json()
+ print(json.dumps(flatten_response_json, indent = 2))
+
+ else:
+ print(flatten_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/flattened-transparencies-pdf.py b/Python/raw JSON calls/flattened-transparencies-pdf.py
new file mode 100644
index 0000000..42b154c
--- /dev/null
+++ b/Python/raw JSON calls/flattened-transparencies-pdf.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ flatten_data = { "id" : uploaded_id }
+ print(json.dumps(flatten_data, indent = 2))
+
+
+ print("Processing file...")
+ flatten_response = requests.post(url='https://api.pdfrest.com/flattened-transparencies-pdf',
+ data=json.dumps(flatten_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(flatten_response.status_code))
+ if flatten_response.ok:
+ flatten_response_json = flatten_response.json()
+ print(json.dumps(flatten_response_json, indent = 2))
+
+ else:
+ print(flatten_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/get-resource.py b/Python/raw JSON calls/get-resource.py
new file mode 100644
index 0000000..35ae3ab
--- /dev/null
+++ b/Python/raw JSON calls/get-resource.py
@@ -0,0 +1,31 @@
+import requests
+import json
+
+# Resource UUIDs can be found in the JSON response of POST requests as "outputId". Resource UUIDs usually look like this: '0950b9bdf-0465-4d3f-8ea3-d2894f1ae839'.
+id = 'xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' # place resource uuid here
+
+# The response format can be 'file' or 'url'.
+# If 'url', then JSON containing the url of the resource file is returned.
+# If 'file', then the file itself is returned.
+format = 'file'
+
+resource_url = f"https://api.pdfrest.com/resource/{id}?format={format}"
+
+print("Sending GET request to /resource/{id} endpoint...")
+response = requests.get(resource_url)
+
+print("Response status code: " + str(response.status_code))
+
+if response.ok and format == 'url':
+ response_json = response.json()
+ print(json.dumps(response_json, indent = 2))
+elif response.ok and format == 'file':
+ # You will find a file (associated with the resource UUID above) in the same folder as the sample when the sample executes successfully.
+ output_file_name = response.headers.get("Content-Disposition").split("filename=")[1]
+
+ with open(output_file_name, 'wb') as f:
+ f.write(response.content)
+
+ print(f"The file {output_file_name} was created.")
+else:
+ print(response.text)
diff --git a/Python/raw JSON calls/gif.py b/Python/raw JSON calls/gif.py
new file mode 100644
index 0000000..8466bfb
--- /dev/null
+++ b/Python/raw JSON calls/gif.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ gif_data = { "id" : uploaded_id }
+ print(json.dumps(gif_data, indent = 2))
+
+
+ print("Processing file...")
+ gif_response = requests.post(url='https://api.pdfrest.com/gif',
+ data=json.dumps(gif_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(gif_response.status_code))
+ if gif_response.ok:
+ gif_response_json = gif_response.json()
+ print(json.dumps(gif_response_json, indent = 2))
+
+ else:
+ print(gif_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/html.py b/Python/raw JSON calls/html.py
new file mode 100644
index 0000000..9e4f142
--- /dev/null
+++ b/Python/raw JSON calls/html.py
@@ -0,0 +1,23 @@
+import requests
+import json
+
+
+data = {
+ 'content': '
Web PageHello World!',
+ 'output': 'example_html_out'
+}
+print("Processing...")
+response = requests.post(url='https://api.pdfrest.com/html',
+ data=json.dumps(data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("HTML response status code: " + str(response.status_code))
+
+if response.ok:
+ response_json = response.json()
+ print(json.dumps(response_json, indent = 2))
+
+
+
+else:
+ print(response.text)
diff --git a/Python/raw JSON calls/jpg.py b/Python/raw JSON calls/jpg.py
new file mode 100644
index 0000000..6878c23
--- /dev/null
+++ b/Python/raw JSON calls/jpg.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ jpg_data = { "id" : uploaded_id }
+ print(json.dumps(jpg_data, indent = 2))
+
+
+ print("Processing file...")
+ jpg_response = requests.post(url='https://api.pdfrest.com/jpg',
+ data=json.dumps(jpg_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(jpg_response.status_code))
+ if jpg_response.ok:
+ jpg_response_json = jpg_response.json()
+ print(json.dumps(jpg_response_json, indent = 2))
+
+ else:
+ print(jpg_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/linearized-pdf.py b/Python/raw JSON calls/linearized-pdf.py
new file mode 100644
index 0000000..017fedf
--- /dev/null
+++ b/Python/raw JSON calls/linearized-pdf.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ linearize_data = { "id" : uploaded_id }
+ print(json.dumps(linearize_data, indent = 2))
+
+
+ print("Processing file...")
+ linearize_response = requests.post(url='https://api.pdfrest.com/linearized-pdf',
+ data=json.dumps(linearize_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(linearize_response.status_code))
+ if linearize_response.ok:
+ linearize_response_json = linearize_response.json()
+ print(json.dumps(linearize_response_json, indent = 2))
+
+ else:
+ print(linearize_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/merged-pdf.py b/Python/raw JSON calls/merged-pdf.py
new file mode 100644
index 0000000..25ec6b1
--- /dev/null
+++ b/Python/raw JSON calls/merged-pdf.py
@@ -0,0 +1,55 @@
+import requests
+import json
+
+with open('/path/to/file1', 'rb') as f:
+ upload_data1 = f.read()
+
+print("Uploading file1...")
+upload_response1 = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data1,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file1.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response1.status_code))
+
+
+with open('/path/to/file2', 'rb') as f:
+ upload_data2 = f.read()
+
+print("Uploading file2...")
+upload_response2 = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data2,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file2.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response2.status_code))
+
+if upload_response1.ok and upload_response2.ok:
+ upload_response_json1 = upload_response1.json()
+ print(json.dumps(upload_response_json1, indent = 2))
+
+ upload_response_json2 = upload_response2.json()
+ print(json.dumps(upload_response_json2, indent = 2))
+
+
+ uploaded_id1 = upload_response_json1['files'][0]['id']
+ uploaded_id2 = upload_response_json2['files'][0]['id']
+ merge_data = { "id" : [uploaded_id1, uploaded_id2], "pages":[1,1], "type":["id", "id"] }
+ print(json.dumps(merge_data, indent = 2))
+
+
+ print("Processing file...")
+ merge_response = requests.post(url='https://api.pdfrest.com/merged-pdf',
+ data=json.dumps(merge_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(merge_response.status_code))
+ if merge_response.ok:
+ merge_response_json = merge_response.json()
+ print(json.dumps(merge_response_json, indent = 2))
+
+ else:
+ print(merge_response.text)
+else:
+ print(upload_response1.text)
+ print(upload_response2.text)
diff --git a/Python/raw JSON calls/pdf-info.py b/Python/raw JSON calls/pdf-info.py
new file mode 100644
index 0000000..8758146
--- /dev/null
+++ b/Python/raw JSON calls/pdf-info.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ info_data = { "id" : uploaded_id, "queries": "title" }
+ print(json.dumps(info_data, indent = 2))
+
+
+ print("Processing file...")
+ info_response = requests.post(url='https://api.pdfrest.com/pdf-info',
+ data=json.dumps(info_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(info_response.status_code))
+ if info_response.ok:
+ info_response_json = info_response.json()
+ print(json.dumps(info_response_json, indent = 2))
+
+ else:
+ print(info_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/pdf-with-added-image.py b/Python/raw JSON calls/pdf-with-added-image.py
new file mode 100644
index 0000000..070faa7
--- /dev/null
+++ b/Python/raw JSON calls/pdf-with-added-image.py
@@ -0,0 +1,55 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data1 = f.read()
+
+print("Uploading file1...")
+upload_response1 = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data1,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response1.status_code))
+
+
+with open('/path/to/file', 'rb') as f:
+ upload_data2 = f.read()
+
+print("Uploading file2...")
+upload_response2 = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data2,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.png', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response2.status_code))
+
+if upload_response1.ok and upload_response2.ok:
+ upload_response_json1 = upload_response1.json()
+ print(json.dumps(upload_response_json1, indent = 2))
+
+ upload_response_json2 = upload_response2.json()
+ print(json.dumps(upload_response_json2, indent = 2))
+
+
+ uploaded_id1 = upload_response_json1['files'][0]['id']
+ uploaded_id2 = upload_response_json2['files'][0]['id']
+ added_image_data = { "id" : uploaded_id1, "image_id": uploaded_id2, "x":0, "y":0, "page":1 }
+ print(json.dumps(added_image_data, indent = 2))
+
+
+ print("Processing file...")
+ added_image_response = requests.post(url='https://api.pdfrest.com/pdf-with-added-image',
+ data=json.dumps(added_image_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(added_image_response.status_code))
+ if added_image_response.ok:
+ added_image_response_json = added_image_response.json()
+ print(json.dumps(added_image_response_json, indent = 2))
+
+ else:
+ print(added_image_response.text)
+else:
+ print(upload_response1.text)
+ print(upload_response2.text)
diff --git a/Python/raw JSON calls/pdf-with-imported-form-data.py b/Python/raw JSON calls/pdf-with-imported-form-data.py
new file mode 100644
index 0000000..2a49883
--- /dev/null
+++ b/Python/raw JSON calls/pdf-with-imported-form-data.py
@@ -0,0 +1,55 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data1 = f.read()
+
+print("Uploading file1...")
+upload_response1 = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data1,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response1.status_code))
+
+
+with open('/path/to/file', 'rb') as f:
+ upload_data2 = f.read()
+
+print("Uploading file2...")
+upload_response2 = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data2,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'data.xml', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response2.status_code))
+
+if upload_response1.ok and upload_response2.ok:
+ upload_response_json1 = upload_response1.json()
+ print(json.dumps(upload_response_json1, indent = 2))
+
+ upload_response_json2 = upload_response2.json()
+ print(json.dumps(upload_response_json2, indent = 2))
+
+
+ uploaded_id1 = upload_response_json1['files'][0]['id']
+ uploaded_id2 = upload_response_json2['files'][0]['id']
+ added_image_data = { "id" : uploaded_id1, "data_id": uploaded_id2, "x":0, "y":0, "page":1 }
+ print(json.dumps(added_image_data, indent = 2))
+
+
+ print("Processing file...")
+ added_image_response = requests.post(url='https://api.pdfrest.com/pdf-with-added-image',
+ data=json.dumps(added_image_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(added_image_response.status_code))
+ if added_image_response.ok:
+ added_image_response_json = added_image_response.json()
+ print(json.dumps(added_image_response_json, indent = 2))
+
+ else:
+ print(added_image_response.text)
+else:
+ print(upload_response1.text)
+ print(upload_response2.text)
diff --git a/Python/raw JSON calls/pdf.py b/Python/raw JSON calls/pdf.py
new file mode 100644
index 0000000..10c6180
--- /dev/null
+++ b/Python/raw JSON calls/pdf.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.png', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ pdf_data = { "id" : uploaded_id }
+ print(json.dumps(pdf_data, indent = 2))
+
+
+ print("Processing file...")
+ pdf_response = requests.post(url='https://api.pdfrest.com/pdf',
+ data=json.dumps(pdf_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(pdf_response.status_code))
+ if pdf_response.ok:
+ pdf_response_json = pdf_response.json()
+ print(json.dumps(pdf_response_json, indent = 2))
+
+ else:
+ print(pdf_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/pdfa.py b/Python/raw JSON calls/pdfa.py
new file mode 100644
index 0000000..06a4e10
--- /dev/null
+++ b/Python/raw JSON calls/pdfa.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ pdfa_data = { "id" : uploaded_id, "output_type": "PDF/A-1b" }
+ print(json.dumps(pdfa_data, indent = 2))
+
+
+ print("Processing file...")
+ pdfa_response = requests.post(url='https://api.pdfrest.com/pdfa',
+ data=json.dumps(pdfa_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(pdfa_response.status_code))
+ if pdfa_response.ok:
+ pdfa_response_json = pdfa_response.json()
+ print(json.dumps(pdfa_response_json, indent = 2))
+
+ else:
+ print(pdfa_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/pdfx.py b/Python/raw JSON calls/pdfx.py
new file mode 100644
index 0000000..5c1d9d3
--- /dev/null
+++ b/Python/raw JSON calls/pdfx.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ pdfx_data = { "id" : uploaded_id, "output_type": "PDF/X-1a" }
+ print(json.dumps(pdfx_data, indent = 2))
+
+
+ print("Processing file...")
+ pdfx_response = requests.post(url='https://api.pdfrest.com/pdfx',
+ data=json.dumps(pdfx_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(pdfx_response.status_code))
+ if pdfx_response.ok:
+ pdfx_response_json = pdfx_response.json()
+ print(json.dumps(pdfx_response_json, indent = 2))
+
+ else:
+ print(pdfx_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/png.py b/Python/raw JSON calls/png.py
new file mode 100644
index 0000000..f5107e7
--- /dev/null
+++ b/Python/raw JSON calls/png.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ png_data = { "id" : uploaded_id }
+ print(json.dumps(png_data, indent = 2))
+
+
+ print("Processing file...")
+ png_response = requests.post(url='https://api.pdfrest.com/png',
+ data=json.dumps(png_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(png_response.status_code))
+ if png_response.ok:
+ png_response_json = png_response.json()
+ print(json.dumps(png_response_json, indent = 2))
+
+ else:
+ print(png_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/restricted-pdf.py b/Python/raw JSON calls/restricted-pdf.py
new file mode 100644
index 0000000..2649e8f
--- /dev/null
+++ b/Python/raw JSON calls/restricted-pdf.py
@@ -0,0 +1,40 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ restrict_data = { "id" : uploaded_id, "new_permissions_password": "password", "restrictions": ["print_low", "print_high", "edit_content"] }
+
+ print(json.dumps(restrict_data, indent = 2))
+
+
+ print("Processing file...")
+ restrict_response = requests.post(url='https://api.pdfrest.com/restricted-pdf',
+ data=json.dumps(restrict_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(restrict_response.status_code))
+ if restrict_response.ok:
+ restrict_response_json = restrict_response.json()
+ print(json.dumps(restrict_response_json, indent = 2))
+
+ else:
+ print(restrict_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/split-pdf.py b/Python/raw JSON calls/split-pdf.py
new file mode 100644
index 0000000..3072404
--- /dev/null
+++ b/Python/raw JSON calls/split-pdf.py
@@ -0,0 +1,40 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ split_data = { "id" : uploaded_id, "pages": ["1","2"]}
+
+ print(json.dumps(split_data, indent = 2))
+
+
+ print("Processing file...")
+ split_response = requests.post(url='https://api.pdfrest.com/split-pdf',
+ data=json.dumps(split_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(split_response.status_code))
+ if split_response.ok:
+ split_response_json = split_response.json()
+ print(json.dumps(split_response_json, indent = 2))
+
+ else:
+ print(split_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/tif.py b/Python/raw JSON calls/tif.py
new file mode 100644
index 0000000..3f4e743
--- /dev/null
+++ b/Python/raw JSON calls/tif.py
@@ -0,0 +1,39 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ tif_data = { "id" : uploaded_id }
+ print(json.dumps(tif_data, indent = 2))
+
+
+ print("Processing file...")
+ tif_response = requests.post(url='https://api.pdfrest.com/tif',
+ data=json.dumps(tif_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(tif_response.status_code))
+ if tif_response.ok:
+ tif_response_json = tif_response.json()
+ print(json.dumps(tif_response_json, indent = 2))
+
+ else:
+ print(tif_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/unrestricted-pdf.py b/Python/raw JSON calls/unrestricted-pdf.py
new file mode 100644
index 0000000..0fdf26a
--- /dev/null
+++ b/Python/raw JSON calls/unrestricted-pdf.py
@@ -0,0 +1,40 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ unrestrict_data = { "id" : uploaded_id, "current_permissions_password": "password" }
+
+ print(json.dumps(unrestrict_data, indent = 2))
+
+
+ print("Processing file...")
+ unrestrict_response = requests.post(url='https://api.pdfrest.com/unrestricted-pdf',
+ data=json.dumps(unrestrict_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(unrestrict_response.status_code))
+ if unrestrict_response.ok:
+ unrestrict_response_json = unrestrict_response.json()
+ print(json.dumps(unrestrict_response_json, indent = 2))
+
+ else:
+ print(unrestrict_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/upload.py b/Python/raw JSON calls/upload.py
new file mode 100644
index 0000000..678ef80
--- /dev/null
+++ b/Python/raw JSON calls/upload.py
@@ -0,0 +1,19 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/watermarked-pdf.py b/Python/raw JSON calls/watermarked-pdf.py
new file mode 100644
index 0000000..d05819e
--- /dev/null
+++ b/Python/raw JSON calls/watermarked-pdf.py
@@ -0,0 +1,40 @@
+import requests
+import json
+
+with open('/path/to/file', 'rb') as f:
+ upload_data = f.read()
+
+print("Uploading file...")
+upload_response = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response.status_code))
+
+if upload_response.ok:
+ upload_response_json = upload_response.json()
+ print(json.dumps(upload_response_json, indent = 2))
+
+
+ uploaded_id = upload_response_json['files'][0]['id']
+ watermark_data = { "id" : uploaded_id, "watermark_text": "I am watermarked" }
+
+ print(json.dumps(watermark_data, indent = 2))
+
+
+ print("Processing file...")
+ watermark_response = requests.post(url='https://api.pdfrest.com/watermarked-pdf',
+ data=json.dumps(watermark_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(watermark_response.status_code))
+ if watermark_response.ok:
+ watermark_response_json = watermark_response.json()
+ print(json.dumps(watermark_response_json, indent = 2))
+
+ else:
+ print(watermark_response.text)
+else:
+ print(upload_response.text)
diff --git a/Python/raw JSON calls/zip.py b/Python/raw JSON calls/zip.py
new file mode 100644
index 0000000..1840e12
--- /dev/null
+++ b/Python/raw JSON calls/zip.py
@@ -0,0 +1,55 @@
+import requests
+import json
+
+with open('/path/to/file1', 'rb') as f:
+ upload_data1 = f.read()
+
+print("Uploading file1...")
+upload_response1 = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data1,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file1.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response1.status_code))
+
+
+with open('/path/to/file2', 'rb') as f:
+ upload_data2 = f.read()
+
+print("Uploading file2...")
+upload_response2 = requests.post(url='https://api.pdfrest.com/upload',
+ data=upload_data2,
+ headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file2.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+print("Upload response status code: " + str(upload_response2.status_code))
+
+if upload_response1.ok and upload_response2.ok:
+ upload_response_json1 = upload_response1.json()
+ print(json.dumps(upload_response_json1, indent = 2))
+
+ upload_response_json2 = upload_response2.json()
+ print(json.dumps(upload_response_json2, indent = 2))
+
+
+ uploaded_id1 = upload_response_json1['files'][0]['id']
+ uploaded_id2 = upload_response_json2['files'][0]['id']
+ zip_data = { "id" : [uploaded_id1, uploaded_id2] }
+ print(json.dumps(zip_data, indent = 2))
+
+
+ print("Processing file...")
+ zip_response = requests.post(url='https://api.pdfrest.com/zip',
+ data=json.dumps(zip_data),
+ headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
+
+
+
+ print("Processing response status code: " + str(zip_response.status_code))
+ if zip_response.ok:
+ zip_response_json = zip_response.json()
+ print(json.dumps(zip_response_json, indent = 2))
+
+ else:
+ print(zip_response.text)
+else:
+ print(upload_response1.text)
+ print(upload_response2.text)