It was said that he had been formed by Neith, who had been the god of the ancient waters in the Ennead, from a length of spit she had spat at Nu, the god of the ancient waters in the Ogdoad. Some subsequent commentators speculated that Apep must have been an earlier creator, and chief god, thus explaining why he had so much anger towards Ra.
It was believed that Ra (the sun) each night passed into Duat and then battled with Apep, always winning except for certain days in which Ra is momentarily devoured, what the Egyptians saw as an eclipse.
Instead of being worshipped he was done the exact opposite and spat upon. Models would be made of wax and clay and then burnt, spat upon, and defaced.