api sample codes