How to add an exposed filter to a view programatically?
Depends on the filter you need, but, let's say you want to filter by Node type, then you would use the following in a views.inc file included into your module within a hook_views_default_views() function.

$handler-&gt;display-&gt;display_options['filters']['type']['id'] = 'type';
$handler-&gt;display-&gt;display_options['filters']['type']['table'] = 'node';
$handler-&gt;display-&gt;display_options['filters']['type']['field'] = 'type';
$handler-&gt;display-&gt;display_options['filters']['type']['value'] = array(
    'news' =&gt; 'news',
);
$handler-&gt;display-&gt;display_options['filters']['type']['expose']['operator'] = TRUE;


For a sample of what this file may look like, pull up the node.views_default.inc file in the views module. You can also create a view and choose to look at what the code behind it if you need the particular syntax for a filter. The option to export is found at the top right of the view within the edit screen. I would search hook_views_default_views() for additional information.