O'Reilly logo

Drupal 8 Blueprints by Alex Burrows

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exposing Drupal using REST API

Now that we have created out two cars, we need to make them available as an endpoint. To do this is really easy in Drupal 8. We will create a new view just for our cars feed.

So, go to views and create a new view, as shown:

Fig 1.0: Create a view

You will notice there is a new setting at the bottom called REST EXPORT SETTINGS; this is what we are going to use to create our endpoint.

Now, give your view a name of Cars feed and select Content to be of type Cars. Select Provide a REST export and then give it a path; this is the path that will have our data on. Let's use /api/cars and click Save and edit.

Fig 1.1: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required