How to check if up to date with ankiweb server?

I’m building an add-on and one feature that I need is to determine the most recent time a sync was completed with ankiweb and if possible, if the current deck is up to date with the server. Is this possible?

You could inspect the sync label in the top toolbar to tell if changes are pending, and ‘select ls from col’ for the last sync time.