Happy APIs in Drupal 8
DrupalDay Spain 2015
Juampy NR - @juampynr
Quick guide: How to expose content in Drupal 8
What do you want to do
How you could do it
View, Create, Update and Delete entities.
REST & REST UI modules.
List content.
Use Views REST exports.
Restrict access to your API.
Add an authentication method.
Part one: fetching data
- REST UI
- Views REST exports
Evaluating REST for fetching single entities
Pros
Cons
Easy to set up.
Returns EVERYTHING about an entity.
Can expose all entities (even configuration ones).
Does not support access logic such as "show only my user details".
Supports authentication.
Can't set custom labels.
Listing content with Views REST exports
Image fields in Views REST exports
Paging and filtering in Views REST exports
Evaluating Views REST for listing data
Pros
Cons
Easy to set up.
Does not support authentication (issue).
Supports custom labels, paging and filtering.
Does not report total pages.
Has an API, so it can be extended.
Poor image handling.
Creating an article
Authenticating the request with Basic Auth.
Gotchas on creating/updating
Part three: new and juicy stuff
Provides a language to query our API.
- Dries likes it.
- Work in progress.
Thanks! Questions?
@juampynr
Want to work at Lullabot? Then talk to me.
Happy APIs in Drupal 8
DrupalDay Spain 2015
Juampy NR - @juampynr