This invention discloses a method for dynamically constructing datasets and controllable shared APIs based on
Natural Language Processing (NLP), belonging to the field of
computer software technology. The method includes: receiving a
natural language query input from a user; calling an NLP engine to parse the
natural language query and generate an intermediate representation; dynamically generating
executable query logic based on the intermediate representation and executing it in a secure sandbox environment to obtain the original
result set; analyzing the original
result set, automatically inferring and constructing a structured dataset, and dynamically creating a
data model based on its
metadata; dynamically generating API endpoints at runtime, wherein the API endpoints include
Uniform Resource Locator (URL) paths, endpoint functions bound to the
data model, and automatically injected
authentication dependencies; registering the dynamically generated API endpoints to a
routing table and returning access information. This invention achieves end-to-end automated generation from
natural language requirements to standardized APIs with a unified
authentication mechanism, lowering the development threshold for data services and ensuring production-grade API security.