Web Services in Graph explorer Expand

I wrote a custom plugin to fetch data from an external API. It works well but is only available in it’s own visualization. I would like to fetch data from the graph view, but as far as I understand this is not possible right now. Are there plans for this in future releases?

Has anyone solved it some other way? Not sure if it can be done by contextual scripts?

Hello Martin,

the graph browser “officially” is not supporting nodes that are not in elasticsearch.
However, you can still import them if you have the corresponding entity in your data model and get a functioning graph (to a certain degree).
I wrote the following contextual script as an example. It will fetch the JSON data form the URL in the first line and convert the result into graph nodes (using the Companies entity that is available in our demo data)

var url='https://financialmodelingprep.com/api/v3/profile/AAPL?apikey=demo';

function beforeAll(graphId, graphModel, graphSelection) {
  var Http = new XMLHttpRequest();
  Http.open('GET', URL);
  Http.setRequestHeader('Content-Type', 'application/json');
  Http.send();
  return new Promise((resolve, reject) => Http.onload = () => {
    Http.status === 200 ? resolve(Http.responseText) : reject(Http.responseText);
  })
    .then(function (data) {
      var jsonData = JSON.parse(data);
 
      for (var i = 0; i < jsonData.length; i++) {
        var elmt = jsonData[i];

        var newNode = {
          color: '#B83B6E',
          entityId: 'search:Companies',
          fontIcon: 'far fa-building',
          id: "company/Company/" + elmt.isin,
          indexPattern: 'index-pattern:company',
          label: elmt.companyName,
          pathIcon: null,
          payload: elmt,
          size: 1,
        };
    
        graphModel.nodes.push(newNode);
      }
  
      return {
        model: graphModel,
        selection: graphSelection
      };
    })
    .catch(function(response) {
      console.log('rejected', response)
    });
}

Our plans for the future are to have better integration with external web services.
Hope this helps you for now

1 Like

Very nice Fabio. I will see if I can set this up on my machine.

I would strongly suggest to be able to invoke Web Services functions from the Graph view in future releases of Siren Investigate.

Thank you!