Clone of https://bitbucket.org/haard/hgapi