Retrieving Predictions

Once a JWT has been retrieved using the /authorize endpoint, you can retrieve predictions for your active ML models. If an invalid JWT is used, the predictions endpoint will return an error.

Get Predictions Based on Identifier

GET https://service.morphlapis.com/predictions/<account>/<models>/get?client_id=<identifier>

Headers Success Error
Authorization:
<token>
{
    "status": 1,
    "<model>": <prediction>
}
{
    status: 0, 
    error: "Error message"
}

In the above table:

  • <account> represents your unique account number, which can be retrieved from the MorphL Dashboard.
  • <models> is a list of models identifiers, separated by /. For example, if <models> = shopping_stage, the endpoint will return the prediction value for the Shopping Stage Completess model. If <models> = shopping_stage/cart_abandonment, the endpoint will return the predictions values for both the Shopping Stage Completess and Cart Abandonment models. Please visit the complete list of unique identifiers for each model.
  • <identifier> is a unique ID for your data. For models that use Google Analytics or Google Analytics 360 data, the identifier represents the Google Analytics Client ID.
  • <token> is the JWT returned by the /authorize endpoint.
  • <model> is a ML model's identifier (see below list). If multiple models are passed in the <models> route parameter, the response will contain a <model>:<prediction> pair for each.
  • <prediction> represents the prediction value, either a float number or a JSON object for multiclass classification ML models.

Quick start

Make request using curl:

$ JWT_TOKEN=eyJ0eXAiOi3erdf4iOiJIUzI1NiJ9.eyJpc3MiOiJtb3...
$ ACCOUNT=92726
$ IDENTIFIER=GA319361.317391

$ curl \
  -X GET \
  -H "Authorization: $JWT_TOKEN" \
  https://service.morphlapis.com/predictions/${ACCOUNT}/shopping_stage/get?client_id=${IDENTIFIER}

Example response

{
    "status":1,
    "shopping_stage":0.8707
}