Prepin
Log in

Create an API to search within a folder.

Approach / Explanation

In this question, the interviewer is requesting you to create a design for an Application Programming Interface (API) that enables searching within a folder. The API serves as a component of a system or service that facilitates communication between different software applications. Specifically, your API should be designed to search within a folder and return relevant results when provided with specific search parameters. To effectively respond to this question, you need to present a clear and logical design for your API. Outline the essential functionalities, including how the API will accept input parameters (such as keywords, file types, etc.), how it will execute the search process, and how it will deliver the results back to the user. Important aspects to address in your response: Explain the purpose and features of the API Describe how the API will retrieve and process the data Indicate how the API will interact with external services

Suggested Answer

The API is designed to search for files within a designated folder. We will develop a RESTful API that utilizes JSON for both requests and responses. A GET endpoint will be created to carry out the search function. The necessary parameters will include the folder path to be searched and the keyword to look for, which will be included in the request URI as query parameters. The API will utilize these parameters to navigate through the specified folder and search for files that exactly match the keyword. The search will be case-insensitive and will return all file types (.txt, .pdf, .docx, etc.) that contain the keyword. Upon successfully completing the search, the API will return a JSON response with a status of 200, along with an array of all matching files, including their names and paths. If no matches are found, it will respond with a status of 404 and a message indicating that no matching files were found.

Alternative Answer

I would create a REST API interface that processes requests and delivers responses in JSON format. The primary endpoint will use the GET method, which takes the folder path and search keyword as input parameters. Upon receiving a request, the API will conduct a thorough search through all files and sub-folders within the specified folder for the search keyword. This search will be case insensitive and will encompass all file types. If the search is successful, the API will respond with a JSON object and a 200 status code. This response will include an array of objects, each representing a file that contains the search keyword, along with its file path and name. In the event that no matching files are found, a 404 status code will be issued, accompanied by a message stating 'No files found.'

Question Details

Difficulty & Category

Medium
system design

Companies

Meta (Facebook)

Product

For CandidatesFor RecruitersCompaniesBrowse JobsInterview QuestionsDeep ProfileSkill AssessmentOpportunity Matching
Prepin.ai

© 2026 Prepin LLC · Philadelphia, PA · All rights reserved.