passes opts to $api function