The earliest written sources for kami worship are the Kojiki of 712 and the Nihon Shoki of 720, and both were compiled at the imperial court for a purpose. They set out a descent from the sun goddess to the reigning line, and they do it at a moment when the court was consolidating its authority and importing Chinese models of statecraft. They are the foundation documents of the tradition and they are political texts, and neither fact cancels the other.
For most of Japanese history the question of what counts as Shinto did not arise in the form modern readers expect. Kami and buddhas were worshipped together in combined institutions for more than a thousand years, with kami understood as manifestations of buddhas or as their protectors, and a single site would house both.
That arrangement was broken deliberately. The Meiji government ordered the separation of kami and buddhas in 1868, and the dismantling that followed removed Buddhist images and clergy from shrines across the country. What emerged was reorganised as a state institution with the emperor at its centre, and it was in that form that Shinto was presented to the world and studied by outsiders for the better part of a century.
Anyone reading about Japanese religion is therefore reading through two reconstructions: one made in the eighth century to legitimate a dynasty, and one made in the nineteenth to build a nation.