How to setup Authentication correctly with Nanonets

How to setup API Keys based Authentication for Nanonets API

Nanonets uses "Basic Authentication" for Authenticating that it is indeed an authorised user making a API request.

In the Basic Authentication schema we use the API Key that can be found here: API Keys as the "username" and the "password" is set to blank. Below are sample using Curl, Postman and Python

Curl

Here is what a sample curl request looks like to get all your OCR models:

curl --user YOUR_API_KEY: https://app.nanonets.com/api/v2/OCR/Models/

Please note that there is a ":" at the end this is split the username and password, but since the password is blank there is nothing following the ":". This is only for Curl example and doesn't apply to the examples below.

Postman

You need to go the Authorization tab and enter your API Key in the Username. The password is blank. The API Key is pasted as is without any modification or any other characters before or after

Python

import requests
url = "https://app.nanonets.com/api/v2/OCR/Models/"
payload = {}
response = requests.request("GET", url, data = payload, auth=('YOUR_API_KEY', ''))
print(response.text.encode('utf8'))

Replace your API Key in the code. The API Key is pasted as is without any modification or any other characters before or after

Was this article helpful?