Drupal 8: Accessing Node values and properties by loading

The node object is loaded by the function load() of Node class of core Drupal system. The object of the node will hold the pieces of information like Content type, created timestamp, author and revision values. Similarly we able to access node field values. The below is the example accessing the Node properties field values of the node.

Syntax: 

use Drupal\node\Entity\Node;
$node = Node::load(NID);
print_r($node);

Node Properties: 

$id = $node->id();
$title = $node->title->value;
$vid = $node->vid->value;

Node field values 

$field1 = $node->get('FIELD_1')->getValue());
$field2 = $node->get('FIELD_2')->getValue());

Examples:

Get Node object: 

use Drupal\node\Entity\Node;
$node = Node::load(NID);
print_r($node); // Node Object.

Node Content Type: 

use Drupal\node\Entity\Node;
$node = Node::load(NID);
print $node->bundle(); // Content type of Node.

Node NID: 

use Drupal\node\Entity\Node;
$node = Node::load(NID);
print $node->id(); // Node Id.

Node Properties(Revision Id, Title, Author Id, Timestamp, etc..): 

use Drupal\node\Entity\Node;
$node = Node::load(NID);
print $node->vid->value; // Revison Id.
print $node->title->value; // Node Id.
print $node->uid->value; // Author Id.
print $node->created->value; // Created Timestamp.

Node Field values: 

use Drupal\node\Entity\Node;
$node = Node::load(NID);
$tags = $node->get('field_tag')->getValue());
print $tags;
// Output.
Array
(
  [0] => Array
    (
      [target_id] => 1
    )
 
)
Category: