Full Scryfall set code coverage
Scryfall has an exhaustive list of all sets and correlated set codes, including promos. 

For example, Dragons of Tarkir Promos are listed as PDTK. While this set uses the same icon as Dragons of Tarkir (DTK), programatically removing the P from a set code as there are valid set codes that begin with P and have a length of four (such as Arena League 1996, PARL). 