The API currently only works if the storeDir is set to the default /nix/store. It would be nice if other stores were supported.
I think this would require to change the API shape a bit.
Instead of /nix/store/<hash>..., load the storeDir and add a prefix: /unpack/<storeDir>/<hash>...