Most tutorials on API integration testing hand you the same recipe: send a GET request, assert the status is 200, check that one JSON field exists, and call it done. That test proves the endpoint answered once, on your machine, at the moment you ran it. It tells you nothing about what your application does when the provider renames a field, returns a null where a number used to be, or classifies a fund as compliant because its holdings coverage collapsed. For a Shariah screening integration, those are the failures that reach users and compliance reviewers, and they all arrive with a perfectly healthy 200 attached.
Table of Contents
- How to Write the First Passing Request Test
- Test Matrix for a Screening Endpoint
- Runnable Test File With pytest
- Why a 200 Is Not Enough
- Handle Null, Unrated and Methodology Cases
- Test Negative Cases Across Tenants and Retries
- Provider Drift and CI Gates
- Confirm the Suite Before You Ship
How to Write the First Passing Request Test
Start with one request you can trust completely, because every negative test you write later is measured against it. Six steps get you there.
Put the key in a server-side environment variable. An API key authenticates requests as its owner, so a key pasted into browser JavaScript or a mobile bundle lets anyone who opens developer tools act as your account. Rotation from the dashboard is recovery after a leak, not prevention of one.
Send one GET request to
/api/v1/compliancefor a ticker in coverage, with the key in anX-API-Keyheader. Theapikeyquery parameter works as well, but headers are far less likely to be written into proxy logs, browser history, or the URL field of an error tracker.Confirm the status is 200 and the
Content-Typeisapplication/json, then parse the body. A 200 carrying an HTML error page from an intermediate proxy parses into an empty object, and every assertion after it fails for the wrong reason.Assert the verdict is one of the documented values, and that the methodology identifier and data period are both present. A verdict with no data period cannot be defended to a reviewer six months later, when the filings behind it have been restated.
Assert every ratio is a number or null, never a string zero. A missing debt ratio that arrives as
0reads as a clean balance sheet and changes an investment decision.Save the sanitized request and response pair as a fixture. That file becomes the deterministic input for your CI run, so pull requests test the same bytes every time.
Here is the anchor row you should keep as your reference response:
verdict: compliant, methodology: AAOIFI, data_period: 2024-Q1 to 2025-Q4, coverage_pct: 92, debt_ratio: null, liquidity_ratio: 0.31
Read that null debt ratio as not computed, never as zero, and check the verdict against the documented set before any business logic runs. The Shariah screening API endpoints quickstart walks through the same authentication setup if you want the request shape confirmed against the live documentation.

The test passes when a parseable JSON body comes back with a verdict from the documented set, a methodology identifier, a data period, and ratios that are numeric or explicitly null. That's your green light.
The same shape scales. A single founder's halal portfolio app and a multi-desk bank's Shariah trading product consume the same JSON structure, so the test you write at this stage carries over to both without a rewrite.
Test Matrix for a Screening Endpoint
One happy-path test is a smoke alarm, not a suite. The matrix below pairs each scenario with the request that triggers it, the status the endpoint should return, and the single assertion that matters most. Copy it into your test plan as rows.
| Scenario | Sample request | Expected status | Key assertion |
|---|---|---|---|
| Valid screening request | GET /api/v1/compliance for a listed ticker with a valid key | 200 | verdict, methodology identifier and data period are present |
| Malformed symbol | ticker containing invalid characters | 400 | no verdict returned and an error body is present |
| Missing or revoked key | request with no key or a revoked key | 401 | body contains no screening data |
| Endpoint outside plan | call to an endpoint the key's plan does not include | 403 | access denied with no partial data |
| Unknown instrument | ticker not in coverage | 404 | no compliant verdict is invented |
| Rate limit exceeded | burst beyond the plan allowance | 429 | Retry-After is respected and no duplicate billable call is made |
| Provider failure | upstream dependency returns an error | 5xx | result is marked unavailable, never compliant |
| Slow response | request with a five-second client timeout | timeout | retry only if the call is safe to repeat |
The anchor row is the valid request, and it earns its place by being the only row where the body must contain a verdict at all. Every other row asserts an absence: no verdict, no partial figures, no compliant label. That distinction matters more than the status code, because a 401 that leaks a cached report is a worse outcome than a 401 that returns an empty error object.
Run the first five rows first. They cover the cases a client meets in the first hour of integration: a typo in the ticker, a key that wasn't loaded, a plan that doesn't include the endpoint, and a symbol that isn't covered. The rate-limit, provider-failure and timeout rows can wait until the happy path is green and stable in CI.
On the 429 row, assert that your client reads Retry-After rather than sleeping for a fixed interval, and that the retry does not produce a second billable call. That's the difference between a polite client and one that pays twice for the same answer.
Runnable Test File With pytest
Here's the file structure that maps one-to-one onto the matrix. Seven steps, and each test name tells you which row failed before you open the traceback.
Create
conftest.pythat reads the test key and base URL from environment variables. No secret in the repository means no rotation scramble after a contractor clones it.Add a fixture that loads recorded responses from a
fixtures/folder. Every pull request then runs deterministically, even when the provider's sandbox is slow or down.Write
test_valid_screening. It sends GET/api/v1/compliancefor a listed ticker with the key in theX-API-Keyheader, asserts status 200, asserts the verdict is in the documented set, assertsmethodologyanddata_periodare present, and asserts every ratio is a number or null.Write one parametrized test over the malformed symbol, unknown instrument and revoked key rows. Parametrizing keeps the assertion logic identical across rows and makes adding a case a one-line change. Each case asserts the expected status and that the body contains no verdict key and no partial figures.
Write
test_rate_limitagainst a mocked 429 that includesRetry-After. Assert the client waits that long and that only one billable call is recorded, because a retry loop that ignores the header is a billing bug with a latency symptom.Write
test_timeoutwith a five-second client timeout. Assert the client only retries when the call is a GET or carries an idempotency key, so a POST that timed out after the server committed doesn't run twice.Name each test after its matrix row.
test_malformed_symbol_returns_400_without_verdictis worth more thantest_compliance_2, because a failing pipeline tells you what broke without a lookup.
# conftest.py
import json, os, pathlib, pytest, requests
BASE_URL = os.environ["AKINDA_BASE_URL"]
API_KEY = os.environ["AKINDA_TEST_KEY"]
FIXTURES = pathlib.Path(__file__).parent / "fixtures"
@pytest.fixture
def client():
s = requests.Session()
s.headers.update({"X-API-Key": API_KEY, "Accept": "application/json"})
return s
@pytest.fixture
def recorded():
def load(name):
return json.loads((FIXTURES / f"{name}.json").read_text())
return load
The fixture layer is where most suites rot. Recording the sanitized pairs once and asserting against them means a red build points at your code or at a genuine provider change, never at network flakiness.
Why a 200 Is Not Enough
A 200 means the server accepted the request and chose to answer it. The 2023 SmartBear survey of more than 1,100 API practitioners across 17 industries shows how mature teams split the work: 77% used automated API testing, 66% monitored APIs in production, and 62% used API design or documentation tools, with developers participating in testing at 57% of organizations. The same page cites a separate 2023 industry summary putting automated API testing at 84% of surveyed testers. The pattern is consistent: validate before release, watch after deployment, and share the work between development and QA.
Status codes carry meaning beyond success or failure. RFC 9110 defines 2xx as success, 4xx as client error and 5xx as server error, and specifies that a status code communicates both the outcome of the request and the semantics of the response. That's why your suite needs a distinct assertion for 400, 401, 403, 404, 429 and 5xx rather than a generic "not 200" check.

What a contract check actually asserts
Compare live responses against the OpenAPI description for paths, methods, headers, content types, required fields, response schemas and documented status codes. Assert application/json on success and error responses alike, since error bodies that switch to text/html break every downstream parser. Check field types explicitly: ratios stay numeric or null, booleans stay boolean, and nullable fields are declared nullable rather than merely tolerated.
Then add the invariants a schema cannot express. A verdict must arrive with a methodology identifier and an effective data period. An unrated result must never be converted into a compliant one. Those are semantic checks, and they belong in the same suite.
The distinction that saves debugging time: a schema failure means the provider changed a type. A semantic failure means the type is fine and the number is wrong. They need different fixes, different owners and different escalation paths, so assert them separately.
Keep one contract test per endpoint for the success shape, plus one negative shape per error class. That's a small suite with wide coverage, and it runs in seconds.
Handle Null, Unrated and Methodology Cases
Financial screening fails without warning. A missing ratio becomes a zero, an uncertain fund becomes a pass, and nobody notices until a reviewer asks why a non-compliant holding appeared in a portfolio. These are the fields and cases that need explicit assertions.
| Field or case | Expected state | Assertion |
|---|---|---|
| Interest-bearing debt ratio not computed | null | field is null and is never read as zero |
| ETF with insufficient coverage | unrated | verdict is not compliant |
| Coverage percentage | numeric value | present alongside every verdict |
| Methodology identifier | named standard such as AAOIFI | matches the methodology requested |
| ETF constituent weights | numbers that sum to the fund total | non-compliant weight is numeric |
| Same company under two standards | verdicts may differ | each result is labelled with its own standard |
Why null beats an estimated zero
A zero debt ratio reads as a clean balance sheet, and downstream logic treats it as a pass. Null says the figure was not computed, which lets the application decide whether to block, warn, or fall back to another source. If your test accepts 0 where null was expected, you've built a system that manufactures compliance.
Unrated is a result, not a failure
Feed the test a fund with partial holdings coverage and assert the verdict is not compliant. Insufficient coverage should produce an unrated result when no breach is already visible, so the application can display uncertainty instead of a false pass. That's a different assertion from "the request failed," and it needs its own fixture.
Methodology mismatch is the quietest bug
The same company can be compliant under one standard and not under another. Request a methodology view and assert that each verdict carries its own standard name and threshold, rather than inheriting the default. A verdict attributed to the wrong methodology is wrong even when the underlying data is correct.
For the ETF weight check, sum constituent weights against a known fixture and assert the total reconciles, because the non-compliant weight feeds purification calculations and a broken sum distorts every downstream number. Run a fixture built around a volatile share price sitting near the 30% AAOIFI line on a twelve-quarter average market capitalisation, so the denominator logic gets exercised rather than assumed. Teams that treat this as an operational monitoring problem as well can lean on API monitoring guidance for SRE teams to pair runtime alerts with the assertions above. If you'd rather see the screening fields before writing the fixtures, the stock screener API documentation lists the response shape.
Test Negative Cases Across Tenants and Retries
The case most suites skip is the cross-tenant one, and it's the one that ends up in a security review. Create at least two isolated test principals, such as separate fintech tenants. Have principal A request a screening report it owns, then request principal B's resource identifier. The expected result is 403 or 404, never a field from B's data.
OWASP's API security testing guidance calls out broken object-level authorization as requiring explicit test cases, because automated scanners cannot infer valid object ownership relationships. Repeat the matrix for missing, expired, malformed and cross-tenant credentials, for endpoints outside the plan, for oversized pagination or batch requests, and for fields that should be read-only.
Practical rule: if a test can pass by returning the wrong tenant's data with a 200, your authorization suite isn't testing authorization.
Classify every call before you retry it
Retries are where resilience testing and billing collide. Safe methods and PUT/DELETE are idempotent under HTTP semantics, meaning a repeated identical request should have the same intended server effect. POST is not, and must not be retried blindly unless the service exposes an idempotency mechanism. Inject a timeout, a connection reset, a 429 and a 5xx, then assert bounded exponential backoff with jitter, a retry limit, and preservation of the original request identity.
Then check what the retry didn't duplicate: webhook registrations, audit events and billable calls. A retry storm that registers the same webhook three times is a resilience bug wearing a reliability costume.
Report latency by request class
Measure p95 and p99 latency and error rate separately for cached, uncached and large-holdings requests. A portfolio call with 400 holdings will always be slower than a single-ticker lookup, and blending them into one average hides the regression that matters. If you want to see how another regulated industry structures these regression suites, browse healthcare QA success stories to see the same pattern of separating critical paths from bulk ones.
Provider Drift and CI Gates
The failure that survives every test above is drift. The provider changes a field type, omits a value, alters an error body, or behaves differently in production than in its sandbox, and your suite stays green because it never asserted the assumption. Postman's 2025 API survey, as reported in a review of API testing tools, put functional and integration testing adoption at 67% each but contract testing at only 17%. Verification often confirms that the integration works today. Few formally verify that the provider still satisfies what the consumer assumes.

Record a consumer-driven contract that lists exactly what your application depends on: verdict as a string, ratios as number or null, the status set per endpoint, and the fields that must never disappear. Check every build against that record. Fixtures for null ratios, unrated ETFs and an expired key then run in milliseconds without touching the network.
Security drift is provider drift too
Failure testing has a security dimension that generic examples skip. Research on API security risks in financial services found that nearly all surveyed organizations experienced at least one API-related security incident in the preceding 12 months, nearly half reported four or more, and only 17% embedded security-focused API testing throughout the API software-development lifecycle and CI/CD pipeline. Use a least-privilege test key separate from production, mask keys, holdings and request bodies before storing them, and simulate provider timeouts without sending production requests.
When a result is unavailable or thinly covered, the suite must confirm the application surfaces it as unknown or unrated rather than compliant. Validate webhook signatures, reject replayed events, and assert that a duplicate delivery changes state once.
Gate the release on the right failures
A failed contract, financial-semantics or authorization test blocks deployment. A failed nightly live test opens an incident without blocking, because live data changes and you don't want a coverage update to freeze a release. Compare coverage percentage against the previous nightly run and treat a drop as a signal. When uptime on the API changelog and release notes shows a provider incident, log it as an incident rather than loosening an assertion. Live uptime and per-endpoint coverage stats are published on our status page at /developer/docs/status and update in real time, so a spike in 5xx responses is visible before your users report it.
Confirm the Suite Before You Ship
Run this checklist before every release. Each item is verifiable in under a minute.
- Happy path green, with verdict, methodology identifier and data period all present.
- All eight matrix rows return their expected status and their stated assertion.
- Null stays null, and unrated stays unrated, including on the ETF fixture.
- Cross-tenant requests return 403 or 404 with no data from the other tenant.
- Retries are bounded and produce no duplicate webhooks, audit events or billable calls.
- The contract file matches the provider's OpenAPI description.
- The nightly live job ran and logged uptime and coverage.
- Logs contain no keys and no holdings.

Keeping a suite fast enough to run on every commit is what makes these gates stick; keeping automated suites fast and trusted covers the maintenance side well.
For your first action, create a test key and open the interactive playground, which lets you pick an endpoint, send a live request with your own key, and copy the request as Shell, Python, Go or 10 more languages. Paste that request into your pytest file and run the first three tests. After a business API contract is signed, API access is granted to the chosen account within 1 business day, so set up the CI key before development starts rather than the morning of your first deploy.
A 200 tells you the request was accepted. Akinda's REST API gives you the verdict, methodology identifier, data period, coverage percentage and null-safe ratios that let your tests assert something stronger, across more than 16,500 stocks and ETFs and five screening methodologies. Create a key, send your first request from the playground, and run the matrix above against it before you wire the integration into anything a client will see. Start at Akinda and build the suite that catches drift before your users do.
