In this paper, we discuss the exclusive photoproduction of ground and excited states of $\psi(1S,2S)$ and $\Upsilon(1S,2S)$ in ultraperipheral collisions (UPCs). Using the potential model in order to obtain the vector meson wave function, we find a good agreement of our calculations with data from the LHC and HERA colliders for $J/\psi (1S,2S) $ and $\Upsilon(1S)$ in $\gamma p$ collisions. We extend the calculations to the nuclear target case applying them to $AA$ UPCs with the use of the shadowing and finite coherence length effects fitted to the data. Our results are compared to the recent LHC data, in both incoherent ($J/\Psi(1S)$ at 2.76 TeV) and coherent ($J/\Psi(1S)$ at 2.76 and 5.02 TeV) processes. We also show the corresponding predictions for the excited states, in the hope that future measurements could provide more detailed information about the vector meson wave functions and nuclear effects.