RESTful API calls and ROOT


Hi everyone,

For a project we need to make some RESTful API calls to fetch some data for analysis inside ROOT. Specifically with an RDataFrame. What is the easiest way to do this?

I know of libcurl as a wrapper for curl, but I’d like to know what other options there are.

ROOT Version: 6.22
Platform: Ubuntu 20.04
Compiler: g++ (I use CMake with c++11)


Hi @decheine ,
and welcome to the ROOT forum!
We can certainly help on the ROOT and RDataFrame side of things, less so in terms of libraries useful to build a RESTful API.

When someone makes an HTTP request to your REST endpoint, what service is listening? Are you writing a C++ HTTP server, or a Python server?

Cheers,
Enrico

Hi @eguiraud,

I believe the REST endpoint is a Flask server written in Python, if you’d like to take a look it’s called ServiceX and the docs for it are here. The program I’m writing will be in C++ and it will be making requests and receiving data from the REST endpoint.

But I’m mainly concerned about what best practices in ROOT exist regarding receiving data from a RESTful server and processing or handling that data with ROOT.

Thanks for the help,
Nick

Hi Nick,
what’s the data format of the data returned by a call to the REST endpoint?

Cheers,
Enrico

The data format can be chosen to be a flat TTree, but also as a Pandas dataframe or an Awkward array. The plan is to choose TTree’s and process the data from the TTree’s to construct an RDataframe.

Alright, then the ROOT/RDataFrame code is completely decoupled from the RESTful backend.
Once you have a TTree, you can use RDataFrame as usual. See the RDF user guide and the related tutorials.

The app sounds interesting, feel free to join ROOT’s mattermost channel to discuss development, I’d be happy to help in case of ROOT-related trouble.
Cheers,
Enrico

EDIT:
and to reply to the original question: I don’t think ROOT has facilities to perform arbitrary HTTP requests.

1 Like