How do I programmatically create a view?
The classic way is to create it manually, via UI, then click "export" (path like http://example.org/admin/structure/views/view/default_demo/export), and wrap resulting code into a module using hook_views_default_views(), maybe fine-tuning details.