Move tags API functions to a new file.
Tags can be sorted alphabetically or by popularity, tidy up API functions.