Getting Started with AWS TranslateText in Python SDK

Khuram Zaman
2 min readApr 13, 2023

Using Tweepy, I’ve been scraping trending topics in India everyday for the past 6 months or so. It’s worked pretty flawlessly (fingers crossed) but some of the tweets are in Hindi.

Instead of manually copy / pasting the trending topic into Google translate in a browser, I wanted to do this as part of the scraping script. So I messed around with two Python libraries: (1) translate and (2) google trans.

The problem with those libraries is that they both ultimately relied on the free version of the Google Translate API. While it worked initially, after a while, I got rate limited. There are approximately 50 trending topics and I was running the script once a day so I didn’t expect to get rate limited so quickly but nonetheless I did.

As all of our apps use AWS, I didn’t want to take time and learn Google Cloud so instead, I decided to try out the AWS TranslateText API.

Here’s how to use the Translate Text API:

  1. Log into the AWS Management Console. Go to IAM and create a new user and/or user group and grant it permissions to the AWS TranslateText API. Make a note or download a csv of the AWS Access Key ID and AWS Secret Access Key. Remember: never put this sensitive information directly in your code.
  2. The AWS TranslateText API comes…

--

--

Khuram Zaman

Adjunct Professor at Georgetown University · CTO of University Startups · Focus: Product Development & LLMs