added apiurl param

Allows the apiurl to be passed as an argument and overridden.