We present PYATB, a Python package designed for computing band structures and related properties of materials using the ab initio tight-binding Hamiltonian. The Hamiltonian is directly obtained after conducting self-consistent calculations with first-principles packages using numerical atomic orbital bases, such as ABACUS. The package comprises three modules: Bands, Geometric, and Optical. In the Bands module, one can calculate essential properties of band structures, including the partial density of states, fat bands, Fermi surfaces, and Weyl/Dirac points. The band unfolding method is utilized to obtain the energy band spectra of a supercell by projecting the electronic structure of the supercell onto the Brillouin zone of the primitive cell. With the Geometric module, one can compute the Berry phase and Berry curvature-related quantities, such as electric polarization, Wilson loops, Chern numbers, and anomalous Hall conductivities. The Optical module offers a range of optical property calculations, including optical conductivity and nonlinear optical responses, such as shift current and Berry curvature dipole. Program summaryProgram title: PYATBCPC Library link to program files:https://doi.org/10.17632/fsfpdy9t5r.1Developer's repository link:https://github.com/pyatb/pyatbCode Ocean capsule:https://codeocean.com/capsule/9408682Licensing provisions: GPLv3Programming language: C++, PythonNature of problem: This program is to study the electronic structure, electronic polarization, band topological properties, topological classification, linear and nonlinear optical response of solid crystal systems.Solution method: Based on the tight binding method to solve the band structure, the Wilson loop is used to classify the topological phases, and the optical response is calculated by Berry curvature and Berry connection.