GET www.wikifunctions.org/w/api.php?action=wikifunctions_run&format=json&function_call={ url_encoded_json_function }

Runs a Function Call in the Wikifunctions orchestration service and returns the response. The Function Call must be formed following the Wikifunctions Function model specifications (See Z7/Function calls section for more details).

For example, the following JSON represents a Function Call to the function Join strings with the input strings "hello, " and "world!":

{
    "Z1K1": "Z7",
    "Z7K1": "Z10000",
    "Z10000K1": "hello, ",
    "Z10000K2": "world!"
}

The API returns an Object of type Z22/Evaluation result.

An Evaluation result object contains two important fields:

  • Z22K1/Response: Contains the output object that resulted of the execution of the given Function Call, if successful. If the evaluation failed, it contains Z24/Void
  • Z22K2/Metadata: Contains a Map object with a collection of key-values that contain information about the evaluation. The keys can contain information about errors, implementation, programming language and version, duration, CPU usage or memory. For a detailed reference of all the possible metadata keys available, see the Metadata documentation in Mediawiki.

Here's an example of a successful Evaluation result object which returns one Metadata key-value: orchestrationDuration:

{
    "Z1K1": "Z22",
    "Z22K1": "hello, world!",
    "Z22K2": {
        "Z1K1": {
            "Z1K1": "Z7",
            "Z7K1": "Z883",
            "Z883K1": "Z6",
            "Z883K2": "Z1"
        },
        "K1": [
            {
                "Z1K1": "Z7",
                "Z7K1": "Z882",
                "Z882K1": "Z6",
                "Z882K2": "Z1"
            },
            {
                "Z1K1": {
                    "Z1K1": "Z7",
                    "Z7K1": "Z882",
                    "Z882K1": "Z6",
                    "Z882K2": "Z1"
                },
                "K1": "orchestrationDuration",
                "K2": "233 ms"
            }
        ]
    }
}

Examples

curl

# Run the Function call Join with the inputs "hello, " and "world!",
# which is represented by the following JSON object:
# {
#    "Z1K1": "Z7",
#    "Z7K1": "Z10000",
#    "Z10000K1": "hello, ",
#    "Z10000K2": "world!" 
# }

$ curl -G https://www.wikifunctions.org/w/api.php \
   --data-urlencode 'action=wikifunctions_run' \
   --data-urlencode 'format=json' \
   --data-urlencode 'formatversion=2' \
   --data-urlencode 'function_call={ "Z1K1": "Z7", "Z7K1": "Z10000", "Z10000K1": "hello, ", "Z10000K2": "world!" }'

Python

# Python 3
# Run the Function call Join with the inputs "hello, " and "world!",
# which is represented by the following JSON object:
# {
#    "Z1K1": "Z7",
#    "Z7K1": "Z10000",
#    "Z10000K1": "hello, ",
#    "Z10000K2": "world!" 
# }

import requests

function_call = '{ "Z1K1": "Z7", "Z7K1": "Z10000", "Z10000K1": "hello, ", "Z10000K2": "world!" }'

url = 'https://www.wikifunctions.org/w/api.php'
params = {
    "action": "wikifunctions_run",
    "format": "json",
    "formatversion": "2",
    "function_call": function_call
} 

response = requests.get(url, params)
data = response.json()
print(data)

PHP

<?php
/*
 * Run the Function call Join with the inputs "hello, " and "world!",
 * which is represented by the following JSON object:
 * {
 *    "Z1K1": "Z7",
 *    "Z7K1": "Z10000",
 *    "Z10000K1": "hello, ",
 *    "Z10000K2": "world!" 
 * }
 */

$function_call = '{"Z1K1": "Z7", "Z7K1": "Z10000", "Z10000K1": "hello, ", "Z10000K2": "world!" }';

$url = 'https://www.wikifunctions.org/w/api.php?action=wikifunctions_run&format=json&formatversion=2&function_call=' . urlencode( $function_call );

$ch = curl_init( $url );
$output = curl_exec( $ch );
curl_close( $ch );

echo( $output );
?>

JavaScript

/*
Run the Function call Join with the inputs "hello, " and "world!",
which is represented by the following JSON object:
{
  "Z1K1": "Z7",
  "Z7K1": "Z10000",
  "Z10000K1": "hello, ",
  "Z10000K2": "world!" 
}
*/

let function_call = {
  "Z1K1": "Z7",
  "Z7K1": "Z10000",
  "Z10000K1": "hello, ",
  "Z10000K2": "world!" 
};
let url = 'https://www.wikifunctions.org/w/api.php?action=wikifunctions_run&format=json&formatversion=2&function_call=' + encodeURI( function_call );

let response = await fetch( url );
response.json()
    .then(console.log)
    .catch(console.error);

Parameters

function_call

required string

Url encoded JSON representation of the Function Call to send for is executio. For example:
{
   "Z1K1":"Z7",
   "Z7K1":"Z801",
   "Z801K1":"some text"
}

Responses

200 Success The Function Call was executed successfully. Returns a Result Envelope containing the return value and a map of Metadata objects.
Example
{
    "Z1K1": "Z22",
    "Z22K1": "output object!",
    "Z22K2": {
        "Z1K1": {
            "Z1K1": "Z7",
            "Z7K1": "Z883",
            "Z883K1": "Z6",
            "Z883K2": "Z1"
        },
        "K1": [
            {
                "Z1K1": "Z7",
                "Z7K1": "Z882",
                "Z882K1": "Z6",
                "Z882K2": "Z1"
            },
            {
                "Z1K1": {
                    "Z1K1": "Z7",
                    "Z7K1": "Z882",
                    "Z882K1": "Z6",
                    "Z882K2": "Z1"
                },
                "K1": "orchestrationMemoryUsage",
                "K2": "108.84 MiB"
            },
            {
                "Z1K1": {
                    "Z1K1": "Z7",
                    "Z7K1": "Z882",
                    "Z882K1": "Z6",
                    "Z882K2": "Z1"
                },
                "K1": "orchestrationCpuUsage",
                "K2": "173.821 ms"
            },
            {
                "Z1K1": {
                    "Z1K1": "Z7",
                    "Z7K1": "Z882",
                    "Z882K1": "Z6",
                    "Z882K2": "Z1"
                },
                "K1": "orchestrationDuration",
                "K2": "139 ms"
            }
        ]
    }
}
403 Z559: User not permitted to run Function The user does not have the necessary rights to run a Function Call. For more details see User groups at Wikifunctions.
Example
{
    "error": {
        "code": "wikilambda-zerror",
        "info": "Error of type Z559",
        "message": "User not permitted to evaluate function",
        "zerror": {
            "Z1K1": "Z5",
            "Z5K1": "Z559",
            "Z5K2": {
                "Z1K1": {
                    "Z1K1": "Z7",
                    "Z7K1": "Z885",
                    "Z885K1": "Z559"
                }
            }
        },
        "labelled": {
            "type": "Error",
            "error type": "User not permitted to evaluate function",
            "error value": {
                "type": {
                    "type": "Function call",
                    "function": "Errortype to type",
                    "errortype": "User not permitted to evaluate function"
                }
            }
        }
    }
}
429 Too many requests The limit of concurrent calls has been reached.
Example
{
    "error": {
        "code": "wikilambda_function_call-concurrency-limit",
        "info": "You have too many function calls executing right now."
    }
}
503 Connection error Unable to connect to the Function Orchestrator service.
Example
{
    "error": {
        "code": "wikilambda_function_call-not-connected",
        "info": "Could not resolve host 'http://core-function-orchestrator-1:6254/1/v1/evaluate', probably because the orchestrator is not running. Please consult the README to add the orchestrator to your docker-compose configuration."
    }
}
200 Z502: Validation error The given Function Call is not well formed. The error body will contain the nested sub-errors that better describe the problem. For more information about nesting of validation error, read the Representation of errors page in meta.
Example
{
    "Z1K1": "Z22",
    "Z22K1": "Z24",
    "Z22K2": {
        "Z1K1": {
            "Z1K1": "Z7",
            "Z7K1": "Z883",
            "Z883K1": "Z6",
            "Z883K2": "Z1"
        },
        "K1": [
            {
                "Z1K1": "Z7",
                "Z7K1": "Z882",
                "Z882K1": "Z6",
                "Z882K2": "Z1"
            },
            {
                "Z1K1": {
                    "Z1K1": "Z7",
                    "Z7K1": "Z882",
                    "Z882K1": "Z6",
                    "Z882K2": "Z1"
                },
                "K1": "errors",
                "K2": {
                    "Z1K1": "Z5",
                    "Z5K1": "Z502",
                    "Z5K2": {
                        "Z1K1": {
                            "Z1K1": "Z7",
                            "Z7K1": "Z885",
                            "Z885K1": "Z502"
                        },
                        "Z502K1": "Z523",
                        "Z502K2": {
                            "Z1K1": "Z5",
                            "Z5K1": "Z523",
                            "Z5K2": {
                                "Z1K1": {
                                    "Z1K1": "Z7",
                                    "Z7K1": "Z885",
                                    "Z885K1": "Z523"
                                },
                                "Z523K1": {
                                    "Z1K1": "Z99",
                                    "Z99K1": {
                                        "Z7K1": "Z801",
                                        "Z801": "some input"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        ]
    }
}
200 Z504: Zid not found One of the ZIDs mentioned in the Function Call object cannot be found.
Example
{
    "Z1K1": "Z22",
    "Z22K1": "Z24",
    "Z22K2": {
        "Z1K1": {
            "Z1K1": "Z7",
            "Z7K1": "Z883",
            "Z883K1": "Z6",
            "Z883K2": "Z1"
        },
        "K1": [
            {
                "Z1K1": "Z7",
                "Z7K1": "Z882",
                "Z882K1": "Z6",
                "Z882K2": "Z1"
            },
            {
                "Z1K1": {
                    "Z1K1": "Z7",
                    "Z7K1": "Z882",
                    "Z882K1": "Z6",
                    "Z882K2": "Z1"
                },
                "K1": "errors",
                "K2": {
                    "Z1K1": "Z5",
                    "Z5K1": "Z504",
                    "Z5K2": {
                        "Z1K1": {
                            "Z1K1": "Z7",
                            "Z7K1": "Z885",
                            "Z885K1": "Z504"
                        },
                        "Z504K1": {
                            "Z1K1": "Z6",
                            "Z6K1": "Z1000000"
                        }
                    }
                }
            }
        ]
    }
}
200 Z506: Argument type mismatch The type of an argument instantiated in the Function Call does not match with its function argument definition.
Example
{
    "Z1K1": "Z22",
    "Z22K1": "Z24",
    "Z22K2": {
        "Z1K1": {
            "Z1K1": "Z7",
            "Z7K1": "Z883",
            "Z883K1": "Z6",
            "Z883K2": "Z1"
        },
        "K1": [
            {
                "Z1K1": "Z7",
                "Z7K1": "Z882",
                "Z882K1": "Z6",
                "Z882K2": "Z1"
            },
            {
                "Z1K1": {
                    "Z1K1": "Z7",
                    "Z7K1": "Z882",
                    "Z882K1": "Z6",
                    "Z882K2": "Z1"
                },
                "K1": "errors",
                "K2": {
                    "Z1K1": "Z5",
                    "Z5K1": "Z506",
                    "Z5K2": {
                        "Z1K1": {
                            "Z1K1": "Z7",
                            "Z7K1": "Z885",
                            "Z885K1": "Z506"
                        },
                        "Z506K1": "Z40",
                        "Z506K2": {
                            "Z1K1": "Z6",
                            "Z6K1": "Z6"
                        },
                        "Z506K3": "wrong argument type",
                        "Z506K4": {
                            "Z1K1": "Z5",
                            "Z5K1": "Z542",
                            "Z5K2": {
                                "Z1K1": {
                                    "Z1K1": "Z7",
                                    "Z7K1": "Z885",
                                    "Z885K1": "Z542"
                                },
                                "Z542K1": "Z40",
                                "Z542K2": "Z6"
                            }
                        }
                    }
                }
            }
        ]
    }
}
200 Z507: Error in evaluation Something happened during the execution step which raised an error. The returned value of this error will also include the error propagated from the function evaluator and/or executor services.
Example
{
    "Z1K1": "Z22",
    "Z22K1": "Z24",
    "Z22K2": {
        "Z1K1": {
            "Z1K1": "Z7",
            "Z7K1": "Z883",
            "Z883K1": "Z6",
            "Z883K2": "Z1"
        },
        "K1": [
            {
                "Z1K1": "Z7",
                "Z7K1": "Z882",
                "Z882K1": "Z6",
                "Z882K2": "Z1"
            },
            {
                "Z1K1": {
                    "Z1K1": "Z7",
                    "Z7K1": "Z882",
                    "Z882K1": "Z6",
                    "Z882K2": "Z1"
                },
                "K1": "errors",
                "K2": {
                    "Z1K1": "Z5",
                    "Z5K1": "Z507",
                    "Z5K2": {
                        "Z1K1": {
                            "Z1K1": "Z7",
                            "Z7K1": "Z885",
                            "Z885K1": "Z507"
                        },
                        "Z507K1": {
                            "Z1K1": "Z99",
                            "Z99K1": {
                                "Z1K1": {
                                    "Z1K1": "Z9",
                                    "Z9K1": "Z7"
                                },
                                "Z7K1": {
                                    "Z1K1": "Z9",
                                    "Z9K1": "Z802"
                                },
                                "Z802K1": {
                                    "Z1K1": "Z9",
                                    "Z9K1": "Z42"
                                }
                            }
                        },
                        "Z507K2": {
                            "Z1K1": "Z5",
                            "Z5K1": "Z511",
                            "Z5K2": {
                                "Z1K1": {
                                    "Z1K1": "Z7",
                                    "Z7K1": "Z885",
                                    "Z885K1": "Z511"
                                },
                                "Z511K1": {
                                    "Z1K1": "Z39",
                                    "Z39K1": "Z802K2"
                                },
                                "Z511K2": {
                                    "Z1K1": "Z99",
                                    "Z99K1": {
                                        "Z1K1": {
                                            "Z1K1": "Z9",
                                            "Z9K1": "Z7"
                                        },
                                        "Z7K1": {
                                            "Z1K1": "Z9",
                                            "Z9K1": "Z802"
                                        },
                                        "Z802K1": {
                                            "Z1K1": "Z9",
                                            "Z9K1": "Z42"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        ]
    }
}
200 Z516: Argument value error One of the arguments passed to a built-in Function had a wrong value or type.
200 Z517: Return type mismatch The type returned by a Function Call does not match the expected type from that function definition.
200 Z518: Object type mismatch The Object sent for evaluation is not a Function Call, or one of its arguments cannot be processed or their type evaluated.
Example
{
    "Z1K1": "Z22",
    "Z22K1": "Z24",
    "Z22K2": {
        "Z1K1": {
            "Z1K1": "Z7",
            "Z7K1": "Z883",
            "Z883K1": "Z6",
            "Z883K2": "Z1"
        },
        "K1": [
            {
                "Z1K1": "Z7",
                "Z7K1": "Z882",
                "Z882K1": "Z6",
                "Z882K2": "Z1"
            },
            {
                "Z1K1": {
                    "Z1K1": "Z7",
                    "Z7K1": "Z882",
                    "Z882K1": "Z6",
                    "Z882K2": "Z1"
                },
                "K1": "errors",
                "K2": {
                    "Z1K1": "Z5",
                    "Z5K1": "Z518",
                    "Z5K2": {
                        "Z1K1": {
                            "Z1K1": "Z7",
                            "Z7K1": "Z885",
                            "Z885K1": "Z518"
                        },
                        "Z518K1": "Z7",
                        "Z518K2": "not a function call",
                        "Z518K3": {
                            "Z1K1": "Z5",
                            "Z5K1": "Z502",
                            "Z5K2": {
                                "Z1K1": {
                                    "Z1K1": "Z7",
                                    "Z7K1": "Z885",
                                    "Z885K1": "Z502"
                                },
                                "Z502K1": "Z511",
                                "Z502K2": {
                                    "Z1K1": "Z5",
                                    "Z5K1": "Z511",
                                    "Z5K2": {
                                        "Z1K1": {
                                            "Z1K1": "Z7",
                                            "Z7K1": "Z885",
                                            "Z885K1": "Z511"
                                        },
                                        "Z511K1": {
                                            "Z1K1": "Z39",
                                            "Z39K1": "Z7K1"
                                        },
                                        "Z511K2": {
                                            "Z1K1": "Z99",
                                            "Z99K1": {
                                                "Z1K1": "Z6",
                                                "Z6K1": "not a function call"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        ]
    }
}
200 Z542: Unexpected Object type An Object passed as an Argument has an unexpected type.
Example
{
    "Z1K1": "Z22",
    "Z22K1": "Z24",
    "Z22K2": {
        "Z1K1": {
            "Z1K1": "Z7",
            "Z7K1": "Z883",
            "Z883K1": "Z6",
            "Z883K2": "Z1"
        },
        "K1": [
            {
                "Z1K1": "Z7",
                "Z7K1": "Z882",
                "Z882K1": "Z6",
                "Z882K2": "Z1"
            },
            {
                "Z1K1": {
                    "Z1K1": "Z7",
                    "Z7K1": "Z882",
                    "Z882K1": "Z6",
                    "Z882K2": "Z1"
                },
                "K1": "errors",
                "K2": {
                    "Z1K1": "Z5",
                    "Z5K1": "Z506",
                    "Z5K2": {
                        "Z1K1": {
                            "Z1K1": "Z7",
                            "Z7K1": "Z885",
                            "Z885K1": "Z506"
                        },
                        "Z506K1": "Z40",
                        "Z506K2": {
                            "Z1K1": "Z6",
                            "Z6K1": "Z6"
                        },
                        "Z506K3": "wrong argument type",
                        "Z506K4": {
                            "Z1K1": "Z5",
                            "Z5K1": "Z542",
                            "Z5K2": {
                                "Z1K1": {
                                    "Z1K1": "Z7",
                                    "Z7K1": "Z885",
                                    "Z885K1": "Z542"
                                },
                                "Z542K1": "Z40",
                                "Z542K2": "Z6"
                            }
                        }
                    }
                }
            }
        ]
    }
}