Here and below: the variable is still called `client` in many places. Change to `api`?