Add search API and refactor API