Learning to consume APIs