mirai-translate is an unofficial Mirai Translate API for Python.
pip install mirai-translate
>>> from mirai_translate import Client
>>> cli = Client()
>>> cli.translate('テスト', 'ja', 'en')
'Test'
mirai-translate simply accesses Translation Demo and requests to the behind API server. I believe there is no illegality in using this library. However, you might want to read the Terms of Use for Mirai Translate.