How can I use the UUID API? I am aware that the question is (almost) a duplicate of the following question #21991, which has been posted back in 2012. But that question is NOT related to Drupal 8, where UUID is in core.

References:


Drupal 8 Core API
Drupal 8 Core Module Documentation


The Drupal 8 Core Module Documentation does not list UUID.

I wonder if I could leverage Drupal 8's core UUID module to migrate and map relational data imported from a different environment, which has unique keys generated by Firebase.

Update:

It has been kindly pointed out that UUID is not a module.

It seems to make UUID records per default for entities (aka nodes) and apparently can be used to map entity references.

Can I make use of this when I introduce external data, that already has unique IDs?
So I have the "node" IDs and can map with the UUIDs?

Update based on further comments:

The goal is to use UUID with entities and the REST module.
Respectively, it seems sensible to do so when importing external relational data, that already has unique IDs.

I just try to understand how UUID works, what it can do and what not, how I can generate and validate UUID's, what I need to be aware of, if I introduce external ID's.
I assume what you want to know is how to generate a UUID in Drupal 8, because there's really not much else that you can do ;)

Entities all have an UUID automatically, so if you store your data as a config or content entity, you just have to define the uuid entity key.

To generate a UUID yourself, you need the uuid service:

$uuid = \Drupal::service('uuid');
$uuid-&gt;generate();
$uuid-&gt;isValid($uuid_to_validate);