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
Querying Data via API
00:00
5 left

Querying Data via API

EasySQL · PostgreSQL

Problem

Given an API and dataset, how would you retrieve specific data using that API?

Assume API request metadata and dataset records are stored in the provided tables. Write a PostgreSQL query that returns only records requested by ready API requests and currently marked active.

Output

  1. One row per successfully matched API request and dataset record.
  2. Columns: request_id, dataset_id, record_key, record_value, and requested_at.
  3. Sort by requested_at descending, then request_id ascending.

Schema

api_requests
ColumnTypeDescription
request_idPKINTUnique API request identifier
dataset_idINTIdentifier of the requested dataset
requested_keyVARCHAR(30)Record key requested through the API
request_statusVARCHAR(20)Processing status of the API request
requested_atTIMESTAMPTime when the request was created
dataset_records
ColumnTypeDescription
record_idPKINTUnique dataset record identifier
dataset_idINTIdentifier of the dataset containing the record
record_keyVARCHAR(30)Key used to identify the record
record_valueVARCHAR(100)Value returned for the record
is_activeBOOLEANWhether the record is currently available
Tablesapi_requestsdataset_records
Interviewer

Your question is Querying Data via API. Start with the requirements and the two 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.