Python
Here’s a minimal Python code sample showing how to interact with the API:
import requests
ENDPOINT_HOST = "https://app.vouchsafe.id/api/v1"
# Step 1. Get client ID and secret from the dashboard
CLIENT_ID = "YOUR_CLIENT_ID_HERE"
CLIENT_SECRET = "YOUR_CLIENT_SECRET_HERE"
# Step 2. Trade client id and secret for a time-limited access token
def get_access_token():
response = requests.post(
f"{ENDPOINT_HOST}/authenticate",
json={"client_id": CLIENT_ID, "client_secret": CLIENT_SECRET},
headers={"Content-Type": "application/json"},
)
data = response.json()
return data.get("access_token")
# Step 3. Call an endpoint
def get_verification_by_id(verification_id):
access_token = get_access_token()
if not access_token:
raise Exception("Failed to retrieve access token")
response = requests.get(
f"{ENDPOINT_HOST}/verifications/{verification_id}",
headers={
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json",
},
)
return response.json()
# Step 4. Run the code
if __name__ == "__main__":
verification_id = "YOUR_ID_HERE"
try:
data = get_verification_by_id(verification_id)
print(data)
except Exception as e:
print(f"Error: {e}")