The IDpack SDK - Python cURL source code is a basic example that demonstrates how to use Python cURL to interact with the IDpack API. It provides a straightforward template for sending requests, managing authentication, and handling API responses. This script is ideal for developers seeking a quick and practical way to integrate the IDpack API into their applications.
import requests import json # API USERNAME username = 'YOUR USERNAME' # API USER PASSWORD password = 'YOUR PASSWORD' # API URL url = 'https://api.idpack.cloud/producer/' # SETUP REQUEST DATA data = { "user_secret_key": "YOUR USER SECRET KEY", # ADD USER SECRET KEY "project_secret_key": "YOUR PROJECT SECRET KEY", # ADD PROJECT SECRET KEY "API_Action": "GET_record", # SET API ACTION "API_Search": ["idc_id_number", "10000"], # SPECIFY SEARCH CRITERIA (PRIMARY KEY) "API_OutputFormat": "json", # SET RESPONSE FORMAT (JSON OR XML) "API_Version": "3.2.40" # DEFINE API VERSION } # CONVERT DATA TO JSON (PAYLOAD FOR API) data_string = json.dumps(data) # SET HEADERS headers = { "Accept-Language": "en-US", "Accept": "application/json", "Content-Type": "application/json" } try: # MAKE THE API REQUEST response = requests.post( url, data=data_string, headers=headers, auth=(username, password), timeout=2 # TIMEOUT IN SECONDS ) # HANDLE RESPONSE if response.status_code != 200: print(f"HTTP return code not 200. (Code {response.status_code})") else: print(response.text) except requests.exceptions.RequestException as e: # HANDLE EXCEPTIONS (e.g., TIMEOUT, CONNECTION ERROR) print(f"An error occurred: {e}") To explore all the available actions, understand how to structure your API requests, and review detailed information about the JSON response format, please visit the IDpack API - Reference section. This comprehensive resource provides in-depth documentation, including examples of API calls, expected responses, and explanations of the parameters and their uses. It is an essential guide for developers working on integrating the IDpack API into their systems.