first make sure that api is public. and i'm hopping that it's public what i can see the issue is headers maybe you have to give proper headers Just user-agent won't works
there can be other issues as well like rate-limits, CORS erros (check console) also make sure parameters are correct.
Just test it on normal browser to find exact issue