I won't lecture you on the inherent limitations of gloss translations, they are indeed useful some times.
As you know, translation UIs as well as Wiktionary and many other sites give more complete information, but the translation APIs do not.
For Google Translate, some unofficial scrapers like GoSlate do offer dictionary data, though without much guidance on how to parse it:
http://pythonhosted.org/goslate/#lookup-details-in-dictionary
That said, there are a few techniques that can lessen the problems of a gloss translation:
Take the longest possible match
Query a dictionary API with the bi- or tri-grams of each sentence first, to find multi-word phrases that are used together often enough to have a dictionary entry.
Use a parts-of-speech tagger
Use a POS tagger on the sentence, then take the matching part of speech returned by the dictionary API.
Use a lemmatiser
Use a lemmatiser to get the canonical ie base form, then do lookup.
[spacy.io is a good lightweight and high accuracy tool for doing [2] and [3] on English data.]