Retrieving Usage Metrics via Javascript/Python Script

Is it possible to retrieve API usage metrics with either a Javascript (preferred) or Python script, rather than using the OpenAI Dashboard for usage. There are other posts related to this, but none seem to have a working script.