The Country Flags entry uses the FlagCDN/Flagpedia service. Its API guide separates flag image URLs from code metadata and includes symbols beyond sovereign countries.
Parse metadata as data and display image responses as images. Define the code set your interface actually needs instead of treating every available flag as a country in a legal or address-selection list.