Question: I would like to programatically populate a paragraph field with a default value for one of my content types.

I came up with the following solution:

```
use \Drupal\Node\NodeInterface;
use \Drupal\paragraphs\Entity\Paragraph;

function my_site_node_create(NodeInterface $node) {
    switch ($node->getType()){
        case 'my_content_type':
            $paragraph = Paragraph::create([
                'type' => 'references',  // paragraph type machine name
                'field_references_title' => [  // paragraph's field machine name
                    'value' => 'Some examples of what we have done' // body field value
                ],
            ]);
            $paragraph->save();

            $node->set('field_paragraphs_content', [
                [
                    'target_id' => $paragraph->id(),
                    'target_revision_id' => $paragraph->getRevisionId(),
                ],
            ]);
            break;
    }

}

```

This code seems to work but im worried I might be creating useless Paragraph-entities when the user doesn't save this node (because of the '$paragraph->save()').

How can I avoid this?

Answer: 
The standard solution is to use the [Services module](https://www.drupal.org/project/services), which provides hooks for you to define your own endpoints.

There's also [Restful Web Services](https://www.drupal.org/project/restws) which has similar functionality but is geared more towards entity API integration.

If you literally want to write your own API from scratch then just use your best judgement - there aren't any Drupal-specific standards for that.
You can try [services views](https://www.drupal.org/project/services_views), It can be used with views Module.

> 
> Views support for the Services module version 3.x and later.
> 
> 
> It has currently two features:
>  - Create view based resource creating Services display in a view
>  - Execute any view of the system via views resource call
> 
> 
> Demo video <http://youtu.be/DZEhJKMeR5w>
> 
> 
>