Added federation API code. Not fully working yet