Seeking advise for data exploration project


I’m currently working on a data exploration and visualization project that includes multiple data sources accessible with APIs (mostly REST but not only).
I’d like my assistant to build complex queries across multiple data sources in such a way that it would be possible to split the queries into multiple steps, where each step would involve either an API call or calculation function applied on other steps. The. final goal is to give the user ability to examine the steps, tweak arguments then perform the calculations and visualize the results which would be done in another module.

A simple example: APIs: GetActiveUsers(time_period), GetUsageTime(user, time_period)
Question: “Calculate average usage time for 2023 for each month”
Expected Result (Just an idea):
Step1: FOR date in ‘Jan 2023’ to ‘Dec 2023’
Step2: Call GetActiveUsers(date) → users
Step3: FOR each user in users
Step4: Call GetUsageTime|(user, date) → t
Step5 avg_time += t,
Step6 avg_time = avg_time / count(users)

A non-technical user then should be able to examine the steps, tweak arguments such as ‘date’ or filter the users, then generate the chart. The calculations can be quite complex, such as JOINs or statistical functions.

I’m thinking of defining a custom DSL or JSON based language for output and wondering if someone’s done a similar project because I don’t want to re-invent the wheel. Any ideas? Any assistance of feedback would be appreciated.