I want to make calls to multiple API endpoints. In my case, this is because I don't want to store the whole JSON response in my contract.

If I wanted to get the ?color=red and ?color=blue endpoints, could I use a call like this?


This is a total guess. And it wouldn't allow me to pick out different JSON paths (thing.stuff.0), which I would want.

But I don't see any documentation about it. I am going off this piece of the source code:

contract OraclizeI {
    address public cbAddress;
    function query(uint _timestamp, string _datasource, string _arg) external payable returns (bytes32 _id);
    function query_withGasLimit(uint _timestamp, string _datasource, string _arg, uint _gaslimit) external payable returns (bytes32 _id);
    function query2(uint _timestamp, string _datasource, string _arg1, string _arg2) public payable returns (bytes32 _id);

The first parameter id in the __callbackwill handle different requests in the same callback function.The following is the example dealing with multiple requests.

          contract verifySettlement is usingOraclize {

           uint public price;
           string public landingtime;
           string public expectedtime;`
           string public tempvalue;

            event Log(string text);

            enum oraclizeState { ForActual, ForExpected }

            struct oraclizeCallback {
                  oraclizeState oState;
            mapping (bytes32 => oraclizeCallback) public oraclizeCallbacks;

          function verifySettlement() payable {
                   Log("Contract created.");

          function getActualLandingHour() constant returns (string) {
                return landingtime;

          function getExpectedLandingHour() constant returns (string) {
              return expectedtime;

         function __callback(bytes32 _myid, string _result) {
                 require (msg.sender == oraclize_cbAddress());
                 oraclizeCallback memory o = oraclizeCallbacks[myid];
                 if (o.oState == oraclizeState.ForActual) {
                 else if(o.oState == oraclizeState.Forxpected) {

         function getActualFlightDetails() payable {
                   Log("Oraclize query was sent, waiting for the answer for getting actual flight details..");
                   bytes32 queryId=oraclize_query("URL","");
                   oraclizeCallbacks[queryId] = oraclizeCallback(oraclizeState.ForActual);

         function getExpectedFlightDetails() payable {
                Log("Oraclize query was sent, waiting for the answer for getting actual flight details..");

                bytes32 queryId=oraclize_query("URL","");
              oraclizeCallbacks[queryId] = oraclizeCallback(oraclizeState.ForExpected);

References :- 1) https://medium.com/@crissimrobert/setting-up-of-oraclize-service-in-smart-contracts-9693049b2151

2) How to invoke multiple oracaliszed queries from a single contract

  • This approach is much better than what I was trying!
    – AlexG
    Mar 9 '18 at 6:41
  • I am not going to accept it yet because I would still like to know how to call e.g. query2 or queryN. Along the lines of the query seen in this post, where the API parameters are passed as separate arguments in the oraclize_query function call. I really appreciate your reply and have upvoted, however it's not exactly what I was getting at with the question
    – AlexG
    Mar 9 '18 at 20:43
  • Do you need to know regarding dynamic query?How to update query with dynamic param?Isn't it? Mar 10 '18 at 2:29

I have not tried this yet but essentially, you could make a computation call to Oraclize.

oraclize_query("computation", ["<IPFS Hash>", ... ])

You need to upload a python script to the IPFS network, extracting all values you need from the JSON file and subsequently merging them together into a single string. Here, you can just use for instance a ',' to separate the different results and then add a decode() function to your smart contract for refractoring the string into the different results again.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.