Is there a way to identify total user licenses and allocated licenses via API? We have multiple orgs and we wanted to keep track of license allocated to each org and how many of them are in use vs free by pulling that data from various orgs and showing it in a dashboard or something similar.
I've considered doing this and I don't believe there is a specific API call, the way I was going to do it was to use Selenium and screen scrape the Summary webpage.
There is an API Call available for organization submitted to Pilot Program. Two fields are exposed for WEB SOAP query call if target org has that Pilot Program enabled.
I have created idea to make these fields Generally Available AND available through Apex Code, SOQL, Developer Console and Workbench. You may vote for it if you agree.
Another way is dirty, unreliable and fragile screen scraping. I consider creating custom package which does this job.
Also you might be interested in another related idea.
There are UsedLicenses / TotalLicenses fields from UserLicense object available only through API call and only available for organization subscribed for related Pilot Program.
=== update ===
I created recently a managed beta package which may serve as workaround for this. It screenscrapes company profile page and gets number of total license.
This package includes a User_License_Extended__c custom object which contains Total License number and Used Licenses number ( and some more fields ), these numbers are updated whenever a user is activated or deactivated or user profile is changed assuming package is properly set up with necessary data
Install link for production-like org https://login.salesforce.com/packaging/installPackage.apexp?p0=04t580000001ENa
More details and release notes https://patlatus.wordpress.com/2016/03/07/salesforce-uletas-beta-1-0-release-notes/