Skip to content

Instantly share code, notes, and snippets.

@darraghmckay
Created January 7, 2021 10:09
Show Gist options
  • Save darraghmckay/7f78bbab04f9cc590f0c3c35d4c428fc to your computer and use it in GitHub Desktop.
Save darraghmckay/7f78bbab04f9cc590f0c3c35d4c428fc to your computer and use it in GitHub Desktop.
Inscribe Python2 requests example
import requests
API_KEY = "your-api-key" # https://docs.inscribe.ai/reference#authentication
headers = {'Authorization': API_KEY}
BASE_URL = "https://api.inscribe.ai/api/v2"
# Step 1. Create a customer
customer_response = requests.post(
f"{BASE_URL}/customers",
json={"name": "Unique customer name"},
headers=headers
)
customer_id = customer_response.json()["id"]
# Step 2. Open your file
with open('test.pdf', "wb") as document:
# Step 3. Upload your file
files = {
'file': ("test_file", document, 'application/octet-stream')
}
url = f"{BASE_URL}/customers/{customer_id}/documents"
response = requests.post(url, headers=headers, files=files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment