What is the appropriate way to get items from an entityqueue? I was having trouble finding API examples for entityqueue in Drupal 8.

I ended up writing a query to get the items.

$query = $this-&gt;database-&gt;select('entity_subqueue__items', 'esi')
  -&gt;fields('esi', array('items_target_id'))
  -&gt;condition('esi.bundle', $name_of_queue)
  -&gt;orderBy('delta', 'ASC');

$nids = $query-&gt;execute()-&gt;fetchCol();


But I'd like to use a built in function if possible. Where's the function for retrieving items from an entity queue?
Given $sid is your subqueue id:

$entity_subqueue = \Drupal::entityManager()-&gt;getStorage('entity_subqueue')-&gt;load($sid);


Loads the subqueue object.  You can manipulate this to retrieve or update your entityqueue.

To get the items:

$items = $entity_subqueue-&gt;get('items')-&gt;getValue();


To update the items, add another item to the $items array and then save the entity object:

$items[] = ['target_id' =&gt; 69];

$entity_subqueue-&gt;set('items', $items);

$entity_subqueue-&gt;save();


Voila!

You can check in the database that your entity queue is updated:

select * from entity_subqueue__items where bundle = :sid;


I would like to also add that there is a great alternative to using entityqueue in Drupal 8: the Config Pages module.  It allows you to create entity bundles that have only one entity.  You can then add any field type you like, including entity reference fields.  I recently replaced an entity queue on a project with a config page with an entity reference field, and I preferred the user experience.