Most of Shintō mythology comes from the first volume of the Kojiki, the "Chronicle of Ancient Times". The Kojiki and the Nihonshoki, compiled around the same general time, are the oldest existing Japanese histories, dating from the beginning of the Nara period, early in the 8th Century.The Kojiki was compiled by order of the emperor Tenmu Ten-Nō, around the year 684. Prior to that time, there had been long-circulated histories among the various nobles families, notably works known as the Teiki and Kyūji. Since most of the transmission of these works was by oral recitation, a wide range of variations crept in over the years and became a matter of concern for the Emperor, who ordered the creation of an official version.
This task was given to Hieda no Are (who may or may not have been a woman). The Hieda family had functioned as specialists in oral history (and as oracular priestesses, probably related occupations) for many generations, performing a similar function in Japan as bards like Homer did in ancient Greece. It was said that Hieda no Are only had to hear a piece of literature recited a single time to be able to reproduce it perfectly from memory.
Hieda no Are traveled the country, hearing the differing versions of the nation's history and harmonizing them into a single consistent chronicle.
Are's work was interrupted for a time by the death of Tenmu Ten-Nō in 686, but continued on and off for the next quarter of a century. Finally, in 711, Genmei Ten-Nō ordered the scribe Ō no Yasumaru — written language was a relatively new thing in Japan, imported from China — to set down a text based on Are's research, Are set to dictating and Yasumaru wrote, and the Kojiki was completed in 712.
The Kojiki is a work in three volumes: the first concerns the world of the Kami, and their creation of Heaven and Earth — "Earth" being "Japan", for the most part — and all the things within them. The second and third volumes are concerned with the descent of the Imperial Family, beginning with the legendary Jinmu ("Spirit Warrior") Ten-Nō (660 BCE?) and continuing through to the time of Suiko Ten-Nō (554-628).