This paper describes the design and implementation of stingray, a library in Python built to perform time series analysis and related tasks on astronomical light curves. Its core functionality comprises a range of Fourier analysis techniques commonly used in spectral-timing analysis, as well as extensions for analyzing pulsar data, simulating data sets, and statistical modeling. Its modular build allows for easy extensions and incorporation of its methods into data analysis workflows and pipelines. We aim for the library to be a platform for the implementation of future spectral-timing techniques. We describe the overall vision and framework, core functionality, extensions, and connections to high-level command-line and graphical interfaces. The code is well tested, with a test coverage of currently 95%, and is accompanied by extensive Application Program Interface (API) documentation and a set of step-by-step tutorials.