Effective automation requires a reliable API that returns structured data. Quix.email utilizes an intuitive response architecture where every request returns an execution status and the payload within a result object. This guide demonstrates how to build a Python script that correctly handles these JSON responses.
API Response Structure All responses are formatted as JSON and include three key fields:
-
success (boolean) - indicates if the operation was successful.
-
error (string) - provides an error description (if success is false).
-
result (object) - contains the requested data (if success is true).
Workflow Summary
-
emailGet: Returns an object within result containing id, email, and site.
-
emailCode: Returns an object within result containing the code field (link or activation code).
import requests
import time
API_KEY = "your_api_key"
SITE = "example.com"
DOMAIN = "all"
def get_temp_email():
# Step 1: Request email
url = f"http://quix.email/api/v1/{API_KEY}/emailGet?site={SITE}&domain={DOMAIN}"
resp = requests.get(url).json()
if resp.get("success"):
# The data is in the result field.
res = resp["result"]
print(f"Email: {res['email']} | Activation ID: {res['id']}")
return res['id']
else:
print(f"Error receiving mail: {resp.get('error')}")
return None
def get_activation_code(activation_id):
# Step 2: Waiting for code/link
print("Waiting for a letter...")
for _ in range(12): # Wait up to 60 seconds
time.sleep(5)
url = f"http://quix.email/api/v1/{API_KEY}/emailCode?id={activation_id}"
resp = requests.get(url).json()
if resp.get("success"):
# Extracting code from the nested result object
code = resp["result"]["code"]
print(f"Verification code: {code}")
return code
else:
# If the email hasn't arrived yet, success will be false.
print("The letter has not yet been received...")
print("Waiting time expired.")
return None
# Starting the process
act_id = get_temp_email()
if act_id:
get_activation_code(act_id)
Quix Email

