DarpanX computes reflectivity and other specular optical functions of a multilayer or single layer mirror for different energy and angles as well as to fit the XRR measurements of the mirrors. It can be used as a standalone package. It has also been implemented as a local module for XSPEC (ascl:9910.005), which is accessible through and requires PyXspec (ascl:2101.014), and can accurately fit experimentally measured X-ray reflectivity data. DarpanX is implemented as a Python 3 module and an API is provided to access the underlying algorithms.