If you are asking about the global cooldown, that's easy. It is 1.5 seconds less the haste percentage. Each 10% of haste reduces the GCD by 0.1 seconds, therefore 50% haste makes the GCD 1 second. Yes, you can get some really small fractions, but they do count.
Edit: the documentation page goes on to explain how to get the global cooldown using spellID 61304.
Now, if you are asking about the recycle cooldown of a spell, that's different. Read the code snippet for the API documentation for GetSpellCooldown()
https://wow.gamepedia.com/API_GetSpellCooldown