move createApi function into its own file