This might help you. It details how to understand the parts of the itemstring. Recipe strings should be very similar so a similar set of code should result in what you want.
https://wow.gamepedia.com/ItemLink
EG.
item links include the value item:xxxx which is the type of link followed by its id
Give it a test run as it doesn't specify that it has been updated for BfA so there may be some additional info that they haven't documented.