# RESTful API calls and ROOT

**URL:** <https://root-forum.cern.ch/t/restful-api-calls-and-root/45254>\
**Category:** Newbie\
**Tags:** rdataframe\
**Created:** [June 4, 2021, 7:22pm UTC](https://root-forum.cern.ch/t/restful-api-calls-and-root/45254 "2021-06-04T19:22:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![decheine](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/decheine/32/23692_2.png) [@decheine](https://root-forum.cern.ch/u/decheine)\
**Post date:** [June 4, 2021, 7:22pm UTC](https://root-forum.cern.ch/t/restful-api-calls-and-root/45254/1 "2021-06-04T19:22:35Z")

</div>

* * *

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)

* * *

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [June 4, 2021, 7:42pm UTC](https://root-forum.cern.ch/t/restful-api-calls-and-root/45254/2 "2021-06-04T19:42:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![decheine](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/decheine/32/23692_2.png) [@decheine](https://root-forum.cern.ch/u/decheine)\
**Post date:** [June 8, 2021, 3:42pm UTC](https://root-forum.cern.ch/t/restful-api-calls-and-root/45254/3 "2021-06-08T15:42:17Z")

</div>

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](https://servicex.readthedocs.io/en/latest/). 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

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [June 8, 2021, 4:00pm UTC](https://root-forum.cern.ch/t/restful-api-calls-and-root/45254/4 "2021-06-08T16:00:35Z")

</div>

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

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![decheine](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/decheine/32/23692_2.png) [@decheine](https://root-forum.cern.ch/u/decheine)\
**Post date:** [June 8, 2021, 4:22pm UTC](https://root-forum.cern.ch/t/restful-api-calls-and-root/45254/5 "2021-06-08T16:22:46Z")

</div>

The data format can be chosen to be a flat TTree, but also as a Pandas [dataframe](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html) or an [Awkward array](https://github.com/scikit-hep/awkward-0.x). The plan is to choose TTree’s and process the data from the TTree’s to construct an RDataframe.

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [June 8, 2021, 4:28pm UTC](https://root-forum.cern.ch/t/restful-api-calls-and-root/45254/6 "2021-06-08T16:28:16Z")

</div>

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](https://root.cern/doc/master/classROOT_1_1RDataFrame.html) and the related [tutorials](https://root.cern.ch/doc/master/group __tutorial__ dataframe.html).

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.
