This isn't really a place to code-review your script, even if it uses the API.
Here is were you would publish your script1.
However, after a quick glance at the code, I don't see any glaring problems.
But, if you start making lots, or rapid, calls you will need to check and respect the backoff
value and the quota_remaining
value.
The API documentation is at api.stackexchange.com/docs.
1 You could also ask about specific problems with the API, or you could beg the community to write a Stack Exchange tool for you (script-request).