Web, APIs & Data Integration Interview Questions (Python)
10 Web, APIs & Data Integration questions from the Python track. Read each short answer here, then open a question for the full explanation, examples, common mistakes, and sources.
- Junior
How do you handle JSON coming from an API?
Parse the text with json.loads, then validate the shape and types at the boundary, then convert it to a trusted internal model before using it in application logic.
Read the full explanation - Junior
Why use urllib.parse instead of building URLs by concatenating strings?
Because it encodes parameters correctly (spaces, &, =, and Arabic characters) and splits URL parts safely, whereas manual concatenation breaks URLs and can open vulnerabilities.
Read the full explanation - Mid-level
What are the basic rules for using an HTTP client in Python?
Always set a timeout, reuse a single client (connection pooling), check the status code explicitly, and distinguish transport errors (timeouts and dropped connections) from HTTP errors (4xx and 5xx).
Read the full explanation - Junior
How do you prevent SQL injection when using sqlite3?
Use parameterized queries (placeholders such as ? or :name) and pass the values separately, and never concatenate user input into the SQL text.
Read the full explanation - Mid-level
How do you manage transactions in sqlite3?
Execute a group of changes as an atomic unit: commit when all of it succeeds and rollback if any part fails, and the easiest way is to use the connection as a context manager with conn.
Read the full explanation - Junior
How do you read and write CSV files correctly?
Use the csv module, opening the file with newline="" and an explicit encoding, and use DictReader and DictWriter instead of manual splitting with split(",").
Read the full explanation - Mid-level
What is the problem with naive datetimes in services?
A naive datetime carries no time zone, so it is interpreted according to the machine's settings, causing wrong comparisons and conversions. Store times as aware in UTC and convert to the user's zone only when displaying.
Read the full explanation - Senior
How do you design pagination in an API?
Use offset/limit for simplicity with small, stable data, and a cursor (keyset) for large or changing data, with deterministic ordering and an opaque next token.
Read the full explanation - Senior
How do you keep retries from creating duplicate writes?
Require the client to send a unique idempotency key for each operation, store it with its result in the same transaction, and return the stored result if the same key arrives again instead of executing anew.
Read the full explanation - Senior
How do you separate the API schema from the domain model?
Define request and response models specific to the API (DTOs) for validation and serialization, and convert them to independent internal domain models, so the JSON shape and names do not leak into business logic.
Read the full explanation