How to create a table with a filter?
It can be done by wrapping your table in a form, and then use the form API to render your table and re-render it on submit. You can have a look at this comment: https://www.drupal.org/node/1770512#comment-6428358

In short the render funtion:

function MY_MODULE_build_form($form, &amp;$form_state) {
  // Filter field.
  $form['title'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Title to look for'),
    '#size' =&gt; 15,
    '#default_value' =&gt; isset($form_state['storage']['title']) ? $form_state['storage']['title'] : '',
  );

  // Submit button.
  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t("Find"),  
  );

  // Modify table array here. 
  // If your API supports filters, you can use that too. 
  // My regex is bad, so you might need to tweak this.
  if (isset($form_state['storage']['title'])) {
    $temp_rows = array();

    foreach ($rows as $key =&gt; $row) {
      if (preg_match("/" . $form_state['storage']['title'] . "/", $row['field_to_search'])) {
        $temp_rows[$key] = $row;
      }
    }

    $rows = $temp_rows;
  }

  // Render the table array.
  $form['table'] = array(
    '#theme' =&gt; 'table',
    '#header' =&gt; $header,
    '#rows' =&gt; $rows,
    '#empty' =&gt; t('Empty Rows')
  );      

  return $form;
}


And the Submit function 

function MY_MODULE_build_form_submit($form, &amp;$form_state) {
  // Set the provided filter value in the storage.
  $form_state['storage']['title'] = $form_state['values']['title'];
  // Show the form again.
  $form_state['rebuild'] = TRUE;  
}


You might want to fancy it up with some fieldsets, but those are left out to keep the answer understandable.