Pulled out main joke client api code to separate file