generate api with table reference