There are two main books which contain the history of the kami and the early emperors. Japan is said to be founded in 660 BCE. But historians are fairly certain this date was chosen because it is numerically auspicious date. 660 BCE is a “xīn-yǒu” year in the sexagenary cycle, which according to Taoist beliefs was an appropriate year for a revolution to take place. As a consequence the early emperors have really long reigns much as some of the Old Testament personalities lived a really long time.
The first 13 emperors can be considered to be entirely mythical. This doesn’t mean that someone of that name did not exist, but there is insufficient information to place them either chronologically or geographically. They were probably local chieftains or leaders not leaders of a cohesive complete Japan.
Kojiki
Also Furukotofumi (Japanese: 古事記)
In English it is called the Records of Ancient Matters.
It was written by the courtier O no Yasumaro (? - 723) at the behest of Empress Gemmio (708-715). It was based the oral recitation of Hieda no Are who had been commanded to memorize and maintain this body of work by Emperor Tenmu (622-686). O no Yasumaro completed the work in 712 AD but it first appeared in the reign of Empress Gensho (715-723).
One of two books setting forth the mythological past of Shinto. It was written in Chinese characters, but contains peculiarities of Japanese syntax. It contains a number of songs/poems which are written with Chinese characters but just use the characters phonetically. Some sources suggest the Kojiki represents Japans mythological past before it was greatly influenced by the Chinese. The Kojiki is the oldest surviving book from Japan.
The Kojiki is divided into three parts. The first part, the Kamitsumaki (literally upper roll), concerns the Japanese creation myth. This entails the rising of Japan out of the see and the creation of the earliest and mot powerful kami. The second part, the Nakatsumaki (literally middle roll) covers the first 15 emperors Jimmu Tenno to Emperor Ojin. These stories tie the emperors to the kami and contain a number of mythological elements. The last part, the Shimotsumaki (literally lower roll), covers emperor 16 through 33, Emperor Nintoku to Emperor Suiko (628 A.D.). The last book contains fewer mythic elements than the other books.
The book was written by the court to legitimize the celestial origins of the court and Japan. It contains myths, legends, anecdotes and folk etymologies centered around the imperial and other leading families.
Nihongi
Also Nihon Shoki (Japanese: 日本書紀 or 日本紀)
Referred to in English as the Chronicles of Japan. It is one of two books setting forth the mythological past of Shinto. The Nihon Shoki was finished in 720 under the editorial supervision of Prince Toneri and with the assistance of Ōno Yasumaro. It covers much of the same material as the Kojiki, but the information about the reigns of the later Emperors are considered to be more accurate and the history covers more of the 8th century.
The Nihon shoki focuses on the merits of the virtuous rulers as well as the errors of the bad rulers. It describes episodes from mythological eras and diplomatic contacts with other countries. The Nihon Shoki was written in classical Chinese, as was common for official documents at that time.
The Nihongi is probably a collection of older no longer extant texts.