Create Entity bundles programmatically The Paragraphs module seems great, but it does not provide any API (I looked at the source). So I think that will be enough to use Drupal API and/or Entity API.

About this module: it provides a new entity type 'Paragraph' and field with same name. User can create via UI 'Paragraph types' (bundles) with fields and view display settings like node entity.

My question: What's the right way to define bundle type for this entity type with custom fields in a custom module?

I think I must create fields first, using field_create_field() and field_create_instance() in hook_enable(). But what's next?

I must create bundle for paragraphs entity and attach created field, but I don't know how and any searches always send me to documentation about how programmatically create entity itself.
There is more easy way to do this: Use the module functions.

paragraphs.module contain these functions:


paragraphs_bundle_save()  to create and update bundles
paragraphs_bundle_delete() to remove bundles
paragraphs_bundle_load() to get the list of bundles or load a bundle




/**
 * Implements hook_install().
 */
function MYMODULE_install() {
  // Create new Bundle.
  $bundle = new stdClass();
  $bundle-&gt;name = 'Test Bundle'; // user friendly label
  $bundle-&gt;bundle = 'paragraphy_test'; // machine name
  $bundle-&gt;locked = 0;
  $status = paragraphs_bundle_save($bundle);
}