Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Paginated API with Threads
00:00
5 left

Paginated API with Threads

MediumSQL · PostgreSQL

Problem

An Api is given which is paginated. (Response will not come at once instead you have to call the api with different page numbers in query parameter). You have got K number of threads available write a code which calls this api and returns the whole response.

Asked in the Round 4 (Hiring manager) stage. For this SQL version, the API fetch results are stored by run, page, and item.

Output

  1. Return one row per item from completed runs where every expected page exists and succeeded.
  2. Include run_id, page_number, item_position, and response_payload.
  3. Order by run_id, page_number, and item_position ascending.

Schema

api_runs
ColumnTypeDescription
run_idPKINTIdentifier for one complete API retrieval attempt
expected_pagesINTNumber of pages expected for the run
run_statusVARCHAR(20)Overall status of the API retrieval run
api_pages
ColumnTypeDescription
run_idPKINTAPI run identifier
page_numberPKINTPage number requested from the API
fetch_statusVARCHAR(20)Result of fetching the page
api_items
ColumnTypeDescription
run_idPKINTAPI run identifier
page_numberPKINTPage containing the item
item_positionPKINTItem position within the page
response_payloadVARCHAR(255)Text representation of the API item payload
Tablesapi_runsapi_pagesapi_items
Interviewer

Your question is Paginated API with Threads. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.