Added api v2 support

Yeah, I don't know from where the line came: possibly when I cherry-picked commits from my messed branch. Sorry