Automate your budgeting with the Billing Budgets APIAutomate your budgeting with the Billing Budgets APIGoogle Cloud Developer AdvocateGoogle Cloud Developer Advocate

We’ll also have to make sure the API is enabled, which you can do from the Cloud Billing Budget API page. Each project that you plan to use this API from will need to enable it, which is all the more reason to have a centralized Billing Administration project for projects like these.

Get to the code 

With all the setup done, the next step is to start coding! We’ll work with a quick Python script here to keep it simple but this could be run from anywhere that makes sense for your setup, such as a Cloud Function that you could call whenever a new project gets created. Since we’re using Python and the client libraries here, we’ll first create a virtualenv and then run:

pip install google-cloud-billing-budgets

Now let’s look at some code!