  With the maturation of near-infrared high-resolution spectroscopy, especially
when used for precision radial velocity, data reduction has faced unprecedented
challenges in terms of how one goes from raw data to calibrated, extracted, and
corrected data with required precisions of thousandths of a pixel. Here we
present APERO (A PipelinE to Reduce Observations), specifically focused on
SPIRou, the near-infrared spectropolarimeter on the Canada--France--Hawaii
Telescope (SPectropolarim\`etre InfraROUge, CFHT). In this paper, we give an
overview of APERO and detail the reduction procedure for SPIRou. APERO delivers
telluric-corrected 2D and 1D spectra as well as polarimetry products. APERO
enables precise stable radial velocity measurements on sky (via the LBL
algorithm), good to at least ~2 m/s over the current 5-year lifetime of SPIRou.
