In Search For A New Username

I got back on Twitter, It's like that song "Back to you". It all started after leaving Social Media, first off with Facebook and Instagram. Which wasn't an issue as I seldom used or enjoyed those platforms anymore. I left my old Twitter account @enigmamaker for a couple of reasons, but this is not the place to talk about that.

I needed a Twitter account, as I use the platform for work and keeping up with a couple of good friends of mine. I signed up for a new account with the atrocious handle @kaveen_rodrigo.

Like Joey in the movie Hackers(1995) "I need a handle, man"

Requirments

I wasn't ready for "Master Of Disaster" as my handle yet. I was searching for a handle with the following criteria.

  • Short, Twitter allows only five-characters as a minimum now.
  • Not my name, Unsure why but I'm going to go with my gut on that.
  • Something cool like XKCD, Where I read XKCD was a result of a random string generator.

Random string generator eh? I need exactly that! But also needed to check if Twitter has that username.

Checking with Twitter

As I have a new Twitter account I was afraid that I don't have access for developer credentials. But that wasn't necessary! Upon checking the settings page in developer tools I saw the following request.

1
curl -L -X GET 'https://api.twitter.com/i/users/username_available.json?username=yojack'

That was easy! No authentication a bit of rate limiting is set in place, but who can blame that.

First Attempt

My first ambition was to completely brute force to find all available usernames. This was a bust with strange usernames and rate limiting. I had to narrow down with a prefix that I liked and find matches for that.

Second Attempt

I modified the script to accept the prefix "UKR", Why?

Because "UKR" was part of my intials omitting my second name. My great-grandfather had a signet ring that read the initials "UER", thus I followed suit.

The Python Script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from itertools import permutations
import string, requests, time

twitter_endpoint = "https://api.twitter.com/i/users/username_available.json?username={}"
perm_length = 2

letters = list(string.ascii_lowercase) + ["_"]
permutations = permutations(letters, perm_length)

def writeResult(text):
	f = open("results.txt", "a")
	f.write("{}\n".format(text))
	f.close()

writeResult("Started")
for perm in permutations:
	current = "ukr" + "".join(perm)
	try:
		successful = False
		while not successful:
			page = requests.get(twitter_endpoint.format(current))
			if page.status_code is 200:
				successful = True
				if page.json()["valid"]:
					writeResult(current)
					print("**** Username `{}` Available!".format(current))
				else:
					print("--- Username `{}` Unavailable".format(current))
			else:
				print("--- API Responded with {}".format(page.status_code))
				print("--- Retry in 5 minutes")
				time.sleep(60*5)
	except:
		print("--- Request Failure for username `{}`".format(current))
		pass

In a five letter space with "ukr" as a prefix was an easy job. And then I came across my new handle on the terminal, "ukrhq". HQ as in head-quarters, which I liked partly because "R.E.M" my favourite band's handle was "remhq".

Happy ever after? NO! I had to buy this new domain as well.That's another story for another day.