Update lib/api.php

fix missing variable errors