eldr.ai | ELDR AI - Predictions & Recommendations via API
In the previous sections we looked at Predictions, Recommendations
and Insights. Now let's have a look at the various ways of getting this information from ELDR AI. You can Ask ELDR
via Form, API, CSV, URL, Text and Chart. Here we will explore the API function which is primarily used to integrate Predictions and Recommendations
with your own systems.
You can skip this section if you're not going to use the ELDR AI API.
Navigate to "Ask ELDR" via the Dashboard, side bar or nav menu, and select your Model and Model Variant using the top two
drop downs.
You can toggle any of the Ask Methods (e.g. Form, API etc) by clicking on them.
Click on the API heading:
Requesting Predictions and Recommendations from ELDR AI is straightforward.
The URL to send the request to is https://eldr.ai/api/ask-eldr/{ModelId} (red box). Model Id will be shown by default in the API section -
in this case "287".
We have provided both GET and POST Methods to send the HTTPS request. We have recommended POST simply due to the fact it is best practice to send requests such
as this (with a Body) via POST, however it won't make any difference if you send via GET instead.
The full API Body to send is shown on the left hand side (blue box). By default, by way of example a Body will be automatically created for you
so you can use it for testing/templates. The example will consist of 2 randomly generated "inputs" within range
e.g. to get 2 sets of Predictions and Recommendations. Obviously you can send in as many inputs as you want.
Click on the "ASK ELDR (API)" button to get a response via API - this will be a real response based on the API Body on the left.
This is to there to emulate what you would get back in the API Output section (grey box) for reference, testing and debugging.
Let's explore the API Body and API Output in more detail
API Body
The API Body to send in with your request is JSON.
API KEY - if you are not logged in (as would be the case if you're contacting directly via API and not via the Ask Page), you need to supply
an API KEY in the apiKey field for authentication. You get your API KEY from your User Profile: User Management -> User Details.
Type - determines the coverage - type is always "full" until further notice.
Model Variant Id [OPTIONAL] - you can find this at the top of the page in the Model Variant
dropdown and is displayed by default in the API Body of the Ask Page (in this case 1226) - if you don't send it in, the last viable Model Variant
will be used - modeVariantId.
Inputs - an array of JSON objects, each with input values/categories - you must supply all inputs, spelt
correctly and with a value for each one. Note ipcs e.g. Product have double quotes around the value, whereas ips e.g. Age don't.
That's all you need to send in to get Predictions and Recommendations from ELDR AI.
API Response
Now let's examine the response (API Output) in more detail:
The response comes back in JSON and should be fairly self explanatory:
Expected Input Labels - a list of input labels - for reference and debugging - expectedInputLabels
Output Labels - a list of output labels for reference and debugging - outputLabels
Result - an array of inputs inputs, predictions outputs, ordered predictions outputsOrdered and
recommendations recommendations objects - one result object per set of inputs requested - result.
Success - boolean success of API call success.
That concludes the ELDR AI guide to getting Predictions and Recommendations via API