This isn't really a place to code-review your script, even if it uses the API.  
Here is were you would [**publish** your script](https://stackapps.com/questions/7/how-to-list-your-application-library-wrapper-script-here)<sup>1</sup>.  

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][1] and [the `quota_remaining` value][1].

The **API documentation is at [api.stackexchange.com/docs][2].**

<br>

----------
<sup>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 ([tag:script-request]).</sup>

  [1]: https://api.stackexchange.com/docs/wrapper
  [2]: https://api.stackexchange.com/docs