We derived a general purpose method to retrieve the ultraviolet (UV) spectral irradiance using filtered photodiodes. The algorithm retrieves through an iterative process, which is based on the application of the mean value theorem, the six unknown coefficients of an interpolating polynomial function of order 5. For illustration we retrieve the incident spectral irradiance of three representative study cases. We consider the output currents induced on six SiC filtered photodiodes by a D2 lamp in vacuum, by the same lamp with ozone absorption and by a Martian-like solar spectrum. The algorithm converges to an interpolating function that reproduces the spectrum within the range of response of the photodiodes and with an integral error <0.6% for each channel for the vacuum D2 spectrum. Since two photodiodes are centered on the ozone absorption band, this method successfully detects ozone absorption and estimates its ambient terrestrial concentration with <4% error. This algorithm will be used to retrieve the Martian surface incident spectrum with REMS UV photodiodes on board the MSL Rover mission (NASA). This method can be equivalently used with commercial photodiodes for other applications where an inexpensive, small and light detector is preferred to conventional spectroradiometers.