In the last 15 years, statistical physics has been a very successful framework to model complex networks. On the theoretical side, this approach has brought novel insights into a variety of physical phenomena, such as self-organisation, scale invariance, emergence of mixed distributions and ensemble non-equivalence, that display unconventional features on heterogeneous networks. At the same time, thanks to their deep connection with information theory, statistical physics and the principle of maximum entropy have led to the definition of null models for networks reproducing some features of real-world systems, but otherwise as random as possible. We review here the statistical physics approach and the various null models for complex networks, focusing in particular on the analytic frameworks reproducing the local network features. We then show how these models have been used to detect statistically significant and predictive structural patterns in real-world networks, as well as to reconstruct the network structure in case of incomplete information. We further survey the statistical physics models that reproduce more complex, semi-local network features using Markov chain Monte Carlo sampling, as well as the models of generalised network structures such as multiplex networks, interacting networks and simplicial complexes. arXiv:1810.05095v2 [physics.soc-ph]