Transparent oxide semiconductors hold great promise for many optoelectronic devices such as transparent electronics, UV-emitting devices, and photodetectors. A p-n heterojunction is the most ubiquitous building block to realize these devices. In this work, we report the fabrication and characterization of the interface properties of a transparent heterojunction consisting of p-type NiO and n-type perovskite BaSnO3. We show that high-quality NiO thin films can be epitaxially grown on BaSnO3 with sharp interfaces because of a small lattice mismatch (∼1.3%). The diode fabricated from this heterojunction exhibits rectifying behavior with a ratio of 500. X-ray photoelectron spectroscopy reveals a type II or "staggered" band alignment with valence and conduction band offsets of 1.44 eV and 1.86 eV, respectively. Moreover, a large upward band bending potential of 0.90 eV for BaSnO3 and a downward band bending potential of 0.15 eV for NiO were observed in the interface region. Such electronic properties have important implication for optoelectronic applications as the large built-in potential provides favorable energetics for photo-generated electron-hole separation/migration.