1. Turn on API for all organizations, manually.
2. Generate API key.
3. Get list of orgs that your API key has access to.
4. Build list that correlates org names and org numbers. I like objects in Python for this.
5. Write each org name and each org's results of "Return license state for organization" to a file.
6. Celebrate!