Unit Conversion

Use case request example

API endpoint

Url:

GET /recipe/v2/{id}

Fields:

RECIPE_FIELD_NORMALIZED_INGREDIENTS

Request example(pls use your token and recipe id):

curl -X GET "https://api.whisk.com/recipe/v2/%RECIPE_ID%?fields=RECIPE_FIELD_NORMALIZED_INGREDIENTS" \
-H "accept: application/json" \
-H "Authorization: Bearer %USER_TOKEN%"

We use RECIPE_FIELD_NORMALIZED_INGREDIENTS field to have normalised ingredients with their measurements in response

Response example (for single normalised ingredient):

{
                "analysis": {
                    "alternative_measurements": [
                        {
                            "amount": {
                                "quantity": 120,
                                "unit": "g"
                            },
                            "measurement_system": "MEASUREMENT_SYSTEM_METRIC"
                        },
                        {
                            "amount": {
                                "quantity": 0.5,
                                "unit": "cup"
                            },
                            "measurement_system": "MEASUREMENT_SYSTEM_IMPERIAL"
                        }
                    ],
                    "brand": {
                        "canonical_name": "CANNED FOODS"
                    },
                    "category": {
                        "canonical_name": "CANNED FOODS"
                    },
                    "comment": "drained",
                    "image_url": "<https://whisk-res.cloudinary.com/image/upload/v1552312241/custom_upload/44fa21d42ac048f6d14666536ec27991.jpg>",
                    "product": {
                        "canonical_name": "CANNED TOMATO",
                        "original_name": "canned tomatoes"
                    },
                    "quantity": 0.5,
                    "unit": "cup"
                },
                "id": "b5b42e89c2d9ba4948657ffd42093f078b1c4eb0:4:0",
                "source_text": "½ cup canned tomatoes (drained)",
                "text": "0.5 cup canned tomatoes"
            },

Default quantity and measurement should be taken from analysis.quantity and analysis.unit Default view would containt original ingredients quantity and measurment despite whether it metric or imperial.

If user switches measurement to Metric, on FE we should take quantity and measurement from analysis.alternative_measurments.ammount.quantity and analysis.alternative_measurments.ammount.unit

where "measurement_system": "MEASUREMENT_SYSTEM_METRIC"

Or "measurement_system": "MEASUREMENT_SYSTEM_IMPERIAL" for imperial.

Last updated