getting iCloud space used/available?

I have been thinking of making a little utility to archive files to iCloud. It would be nice to be able to check how much size the user has and how much is unused, but I can’t seem to do this using “size of folder”.

Is there a unix script or ASOC method to obtain this information?

TIA
Vince