"Coffee" is originally an Arabic word that reached the English language through Turkish at some point in the 16th century. Does anyone know the history of the word 咖啡 in Chinese? When did it start appearing in texts, for example? And who would have been the first merchants to bring it to Chinese? Could it be directly from Arabic?
The Chinese wiktionary for 咖啡 says it comes from French, but there's no citation.
The next thing I can reasonably confirm is that 咖啡 appeared in 《中华大字典》, published in 1915.
Given that there are a lot of loanwords from Japanese during this time period, I wouldn't be surprised that 咖啡 is from Japnese as well.
Note: The English wiktionary for the Japnese word 珈琲 suggests it might be influenced by the Chinese word, but it gives no reference. As such, I don't find it credible.
In 1884, an Englishman brought coffee from Manila to Taiwan. The Taiwanese seemed to call it "kopi" (福建话); at approximately the same time (late 1800) a French missionary introduced it to Yunnan province. Coffee consumption in China only started to inch up in late 1990.
I think the word 咖啡 was a direct translation of "cof-fee" by sound.
There seems to be a consensus that it came from English:
Xiandai Hanyu Guifan Cidian says:
That it is a transliteration from English.
Longman’s says the same thing:
英語 coffee 的音譯
Tuttle affixes the following note:
Note: 咖啡 kāfēi is one of the few transliterations (音译词 yīnyìcí) in Chinese vocabulary, as it represents more or less the sound of “coffee.”
Most reference works and dictionaries attribute it as an transliteration from English.