Skip to main content

From Concept to Code: Building a Test Harness for 10K/Day Verification APIs

Learn to build a robust API testing harness capable of handling 10,000+ verification API calls per day. This guide covers architecture, code patterns, and best practices for ensuring high-throughput identity verification API.

From Concept to Code: Building a Test Harness for 10K/Day Verification APIs

Contents

In this guide

Jump to the part you need.

Scalable ArchitectureDesign a testing harness that can simulate high-volume traffic (10,000+ API calls daily) using asynchronous processing and distributed workers.

Realistic Data GenerationImplement strategies for generating diverse, realistic test data, including valid and invalid inputs, to thoroughly test API edge cases and fraud detection capabilities.

Performance MonitoringIntegrate metrics collection and reporting to track latency, error rates, and throughput, ensuring your identity verification API meets strict SLAs.

Automated ValidationDevelop robust assertion mechanisms to automatically verify API responses, including data accuracy, status codes, and security headers, for comprehensive testing.

In the world of identity verification, API reliability and performance are paramount. A single outage or slowdown can have cascading effects, impacting user onboarding, fraud detection, and regulatory compliance. For platforms like Didit, which process thousands of verification requests daily, building a robust API testing harness isn't just good practice—it's a necessity. This guide walks you through the process of designing and implementing a testing harness capable of simulating 10,000+ API calls per day, focusing on practical code examples and architectural considerations.

The Challenge: High-Throughput API Testing

Testing an identity verification API that handles 10,000 requests per day (approximately one request every 8.6 seconds on average, but often in bursts) requires more than simple unit tests. We need to simulate real-world load, diverse data inputs, and various network conditions. The goal is to ensure the API remains performant, accurate, and secure under stress.

Key challenges include:

  • Volume: Simulating 10K API calls daily, potentially peaking at hundreds per minute.
  • Data Diversity: Generating unique and realistic test data for ID documents, biometrics, and user profiles.
  • Realism: Mimicking user behavior, including valid requests, invalid inputs, and potential fraud attempts.
  • Validation: Accurately verifying complex API responses, including biometric match scores, document authenticity, and AML screening results.
  • Performance: Measuring latency, throughput, and error rates to identify bottlenecks.

Architecting Your API Testing Harness

A successful API testing harness for high-throughput scenarios typically involves several components:

  1. Test Orchestrator: A central component responsible for scheduling, distributing, and managing test runs.
  2. Worker Nodes: Distributed processes that execute API calls concurrently.
  3. Data Generator: A module to create realistic and varied test data.
  4. Assertion Engine: Logic to validate API responses against expected outcomes.
  5. Reporting & Monitoring: Tools to collect performance metrics and visualize results.

Let's consider a Python-based example, leveraging libraries like requests for HTTP calls, asyncio for concurrency, and pydantic for data modeling.

1. Data Generation for Identity Verification

Generating realistic identity data is crucial. This involves creating simulated ID document numbers, names, dates of birth, and even synthetic biometric data (e.g., image placeholders for face match). For 10K API calls a day, you can't manually create data.


import random
from datetime import datetime, timedelta
from faker import Faker

fake = Faker()

def generate_id_data():
    return {
        "document_type": random.choice(["passport", "driving_license", "id_card"]),
        "document_number": fake.bothify(text='????######', letters='ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
        "first_name": fake.first_name(),
        "last_name": fake.last_name(),
        "date_of_birth": (datetime.now() - timedelta(days=random.randint(18*365, 60*365))).strftime('%Y-%m-%d'),
        "country": random.choice(["US", "GB", "DE", "ES"]),
        "image_data_base64": "simulated_id_image_base64_string" # Placeholder
    }

def generate_liveness_data():
    return {
        "selfie_image_base64": "simulated_selfie_image_base64_string" # Placeholder
    }

def generate_aml_data(id_data):
    return {
        "name": f"{id_data['first_name']} {id_data['last_name']}",
        "date_of_birth": id_data['date_of_birth'],
        "country": id_data['country']
    }

# Example usage:
id_payload = generate_id_data()
print(id_payload)

For biometric data, you'd typically use placeholder image data or a set of known valid/invalid images stored locally or in a cloud bucket, referencing them dynamically. Didit's API, for instance, accepts base64 encoded images, making this straightforward.

2. Concurrent API Call Execution

To achieve high throughput, asynchronous execution is key. Python's asyncio with aiohttp is an excellent choice for this.


import aiohttp
import asyncio
import time

API_BASE_URL = "https://api.didit.me/v1"
API_KEY = "YOUR_DIDIT_API_KEY"

async def call_verification_api(session, endpoint, payload):
    headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
    start_time = time.time()
    try:
        async with session.post(f"{API_BASE_URL}/{endpoint}", json=payload, headers=headers) as response:
            response_time = (time.time() - start_time) * 1000 # ms
            status = response.status
            data = await response.json()
            return {"status": status, "data": data, "latency": response_time, "success": True}
    except aiohttp.ClientError as e:
        response_time = (time.time() - start_time) * 1000 # ms
        return {"status": 0, "data": {"error": str(e)}, "latency": response_time, "success": False}

async def run_test_scenario(num_calls=100):
    async with aiohttp.ClientSession() as session:
        tasks = []
        for _ in range(num_calls):
            id_data = generate_id_data()
            # Example: call ID verification and then Liveness
            tasks.append(call_verification_api(session, "id-verification", id_data))
            tasks.append(call_verification_api(session, "liveness", generate_liveness_data()))
        
        results = await asyncio.gather(*tasks)
        return results

# To run:
# if __name__ == "__main__":
#    test_results = asyncio.run(run_test_scenario(num_calls=100))
#    print(f"Completed {len(test_results)} API calls.")

This pattern allows you to send multiple requests concurrently, dramatically increasing your throughput for your identity verification API reliability testing.

3. Robust Assertion and Validation

After receiving responses, you need to validate them. For identity verification, this means checking not just HTTP status codes, but also specific fields within the JSON response, like verification_status, match_score, or aml_hits.


def validate_id_verification_response(response):
    assert response["success"] is True, f"API call failed: {response['data'].get('error')}"
    assert response["status"] == 200, f"Expected 200, got {response['status']}"
    assert "verification_status" in response["data"], "Missing 'verification_status' in response"
    assert response["data"]["verification_status"] in ["ACCEPTED", "REJECTED", "REVIEW"], "Invalid verification status"
    print(f"ID Verification Latency: {response['latency']:.2f}ms")
    # Further checks based on specific Didit API response structure

def validate_liveness_response(response):
    assert response["success"] is True, f"API call failed: {response['data'].get('error')}"
    assert response["status"] == 200, f"Expected 200, got {response['status']}"
    assert "liveness_status" in response["data"], "Missing 'liveness_status' in response"
    assert response["data"]["liveness_status"] in ["LIVE", "SPOOF"], "Invalid liveness status"
    print(f"Liveness Latency: {response['latency']:.2f}ms")

How Didit Helps

Didit provides a robust identity verification API designed for high-throughput environments. Our API is modular, allowing you to combine ID verification, passive liveness, face match, and AML screening into custom workflows. The Didit Business Console offers real-time analytics and audit logs, which are invaluable when building and testing your API testing harness.

  • Predictable API Responses: Our API documentation clearly defines response structures, making it easier to build robust assertion logic.
  • Sandbox Environment: A dedicated sandbox allows you to test extensively without incurring costs or affecting production data.
  • Webhooks: Configure webhooks to receive real-time notifications of verification outcomes, useful for asynchronous testing scenarios.
  • Scalable Infrastructure: Didit's infrastructure is built to handle massive loads, ensuring your test harness accurately reflects real-world performance against a reliable backend.

Optimizing for 10K API Calls Daily

To truly hit 10,000+ API calls per day, consider these optimizations:

  • Distributed Workers: Deploy your test script across multiple machines or containers (e.g., using Docker and Kubernetes) to scale concurrency beyond what a single machine can handle.
  • Test Data Management: Use a database or a robust file system to manage a large pool of test data, preventing repetition and enabling specific test cases (e.g., known fraud patterns).
  • Rate Limiting & Throttling: Be mindful of any rate limits on the API you're testing. Design your harness to respect these limits or simulate bursting behavior within limits.
  • Error Handling & Retries: Implement intelligent retry mechanisms for transient errors to improve test stability.
  • Performance Baselines: Establish clear performance baselines (latency, throughput) and monitor deviations over time.

Ready to Get Started?

Building a custom API testing harness for high-volume identity verification ensures your systems are always performing optimally. With Didit's flexible API and comprehensive documentation, you have the ideal partner to build, test, and deploy robust identity solutions. Explore our developer documentation or sign up for a free account to start building your resilient verification workflows today.

Try it

Try this in the sandbox

Run the check this guide describes, free.

ID Verification

The product this post is about, taken from its topic. Run it free in the sandbox.

$0.15 per checkStart free

Author

Alejandro Rosas

Co-founder and CTO

Alejandro Rosas

Alejandro Rosas

Co-founder and CTO

About Didit

Questions

FAQ

What is an API testing harness?

An API testing harness is a framework or set of tools designed to automate the process of sending requests to an API, receiving responses, validating those responses against expected outcomes, and reporting on the API's behavior, performance, and reliability.

Why is high-throughput API testing crucial for identity verification?

High-throughput API testing for identity verification ensures that the system can handle a large volume of user onboarding and authentication requests without compromising speed, accuracy, or security. It prevents bottlenecks, identifies performance issues under load, and verifies the reliability of critical fraud detection and compliance checks.

What are the key components of a robust API testing harness?

A robust API testing harness typically includes a test orchestrator to manage runs, worker nodes for concurrent execution, a data generator for realistic inputs, an assertion engine for response validation, and comprehensive reporting and monitoring tools for performance analysis.

How can I generate realistic test data for identity verification APIs?

Realistic test data can be generated using libraries like Faker to create synthetic names, addresses, and dates. For document and biometric data, you can use placeholder images or a curated set of reference images, ensuring diversity to cover various scenarios including valid, invalid, and edge cases for fraud detection.

Compliance built in

Audited, certified and attested.

We hold the certifications and build each country's rules into your flows, so you can launch anywhere without worrying. Security and Compliance center

  • Regulation encoded into your flows

    Tell us what you do and where. Didit lists the rules that apply to you, with sources, and builds the checks each country needs into one workflow.

  • Ready for AMLR

    Every requirement of the new EU anti-money laundering rules, from checking customers to human review, is already covered by a Didit check.

  • Tested in Spain's Treasury sandbox

    Spain's Treasury published its supervised sandbox report on Didit's NFC plus active liveness onboarding; SEPBLAC took part and valued the added measures positively.

  • Audited, not self-declared

    iBeta Level 1 and Level 2. Liveness tested under ISO/IEC 30107-3.

Compliance assistant

Your obligations · 3 regions

EU · AMLRCustomer due diligence, human reviewCovered
Illinois, Texas, ColoradoExplicit biometric consentCovered
Germany · Youth protectionVerified adults only (JMStV)Covered
Workflow checked. Every obligation is met
  • SOC 2 Type 2
  • ISO 27001
  • iBeta Level 1 and Level 2
  • EU regulator attestation
  • FSM youth protection
  • GDPR
  • EBA remote onboarding
  • MiCA compatible
  • FIDO Alliance member
  • AMLREU AML Regulation ready

Integration · Didit MCP

Run Didit from your own AI agent

Connect Didit to Claude, Cursor, VS Code or ChatGPT and just ask in plain words. Your agent can do anything you can do in the console, with the same permissions you have.

Add to ClaudeChatGPT
Didit Academy · Lesson 04 · Use Didit with MCP
  • Build workflowsDescribe the checks you need. The agent creates and publishes the flow.
  • Run investigationsAsk why a session was declined, review cases, search people and companies.
  • Change rulesCreate payment rules, test them on past data and switch them on.
  • Pull reportsAsk for numbers, exports or the audit log.

Verify your first user today.

Start free

Free sandbox. Credit applies to work-email sign-ups.