Taxonomy field in code
Create a vocabulary  with fields

taxonomy_vocabulary_save((object) array(
      'name' =&gt; 'Vocabulary Name',
      'machine_name' =&gt; 'vocabulary_machine_name',
    ));

// Create a field
 $field = array(
    'field_name' =&gt; 'field_your_field',
    'type' =&gt; 'text',
    'label' =&gt; 'your label'
  );
  field_create_field($field);

  // Attach the field to our taxonomy entity
  $instance = array(
      'field_name' =&gt; 'field_your_field',
      'entity_type' =&gt; 'taxonomy_term',
      'bundle' =&gt; 'vocabulary_machine_name',
      'label' =&gt; 'Label',
      'description' =&gt; 'Description',
      'required' =&gt; true,
      'widget' =&gt; array(
        'type' =&gt; 'text_textfield',

      )
  );
  field_create_instance($instance);


You can create terms like below :

 $term = new stdClass();
    $term-&gt;name = ‘Your Term name’;
    $term-&gt;vid = 'vocabulary id'; 
    $term-&gt;field_your_field[LANGUAGE_NONE][0]['value'] = ‘data’; 
    taxonomy_term_save($term);