 Okay, hello everyone. I'm more than happy to welcome you on my session My name is Miram Helychka and so currently I'm working on pet wrappers. I have more than five years experience with Web development in general and so with Drupal. I'm working for More than three years. I'm also a board member of the Royal Drupal Association So what we are going to talk about in this presentation? In the beginning I will talk a little about API designing best practices Then I will tell what the coupling is and so how we can use it in Drupal 7 and in Drupal 8 and In the end of my presentation, I will get to my hobby project where I use Drupal 8 and In terms of things. So let's start with API best practices The first is documentation because if you don't have your API will document it Nobody will use it today tools like apre or apgen I think are quite common and You can easily generate from your Program to API of documentation for it Though the other point is stability and consistency If you are if you ever have ever used Facebook API, you probably know it's not where it's not very consistent It's changing constantly at is not helping developer experience Oh So also the consistency you should you shouldn't have multiple Endpoints for one resource and etc The other point is flexibility because when you are designing API, we should be used by of front-enders as well as backend people you probably need to Explode data in multiple formats, not only JSON for front-end users, but it should be helpful for backend integrations to have XML or some other formats Then security or the security is probably the only of these five points of which Drupal Accomplish quite successfully Security is quite common you can use Mostly come on Token authentication, so you have token generated for user or for your application and you are sending it in your header Then you can use I don't know HTTP Authentication or digest authentications The last point is of adoption is quite summary of the previous points because if you don't have any Of these Probably your API wouldn't be very helpful for developers Let's move to the coupling. What the coupling mean on someone's imagine is as this like headless Drupal But what it really is you may imagine it as Drupal in the middle then some application requesting data from it It also don't have to be only one way communication Between Drupal and these applications This application can also write Drupal and these applications can also communicate with each other So what are some pros and cons of the coupling or pros you will get flexible front-end So your front-enders will be happy because they can use up-to-date technologies with Drupal 7 There were there was quite all jQuery in Drupal 8. It's Moving forward you can use Modernizer and all these cool front-end libraries The other pros is also The day you can solve lack of Drupal specialist because there is There isn't a lot of front-enders who are willing to work with Drupal front-end So you can easily solve this issue As I showed in previous screen, you can use multi-vendor back-end So you can display data from multiple application in our one presentation application for end-user and The last point is that you can still use strength of Drupal back-end and more More importantly also Drupal back-office if you design your decoupled application quite well And cons are that you will lose some Drupal capabilities. So I am speaking mostly about some adjustments for Disabled people, you know, there are some of this why are you attacks for Screen readers and these things also you will probably need to program this You will also have to make multiple Requests for one resource because or for resources on the page Because you basically have multiple elements on the page and you need to request for Almost each of them, but this don't have to be issue with HTTP to protocol and The last call is a grow-off team because you will need more specialists You will need Drupal specialists, then you will probably need some integration specialist and Lastly, you will need some front-end specialists What solution for this for some of these cons or you don't have to make a full decoupling way you can use Something called big pipe. I think there is presentation about it right now. It's kind of caching mechanism where you first load cached page elements like headers and static products and then you are dynamically loading Personalized content of the page Now with a quick look on Drupal 7 decoupling capabilities There are basically three modules for this or There is restful web services module which is Basically base of Drupal address module so you can use it and easily migrate to Drupal 8 then It's partially OOP, but it doesn't provide versionable API. I Feel that versioning of API is one of the most important things because You might need more versions of your of your data The other module is Services module or this probably the most common solution in Drupal 7 The cool thing about this module is That it have active Drupal 8 branch So you will probably Know how to use it if you were using it in Drupal 7 It also provides some capabilities of version versionable API But it's written fully in procedural way, but if we are looking on it in Drupal 7 context Don't have to be On the last module I found is probably the best one. I didn't have found. I didn't find any Cons of it It's fully OOP. It provides Versionable API, so we should be really really happy about this module With Drupal 8 There were quite changes Regarding rest Rest is now in core. There are I think four modules of providing rest capabilities But There is always but Even if we have core Resting core it doesn't provide versionable API and there is about 60 issues in Beglock and some of the issues are quite important also for working with these modules Also in Drupal 8 you have The rest module as basic for providing endpoints and then you have rest output from views Integration there are some other modules for different formats than JSON like for XML and And other Some people try to Make it better So restful module is also for Drupal 8, but it hasn't been developed for quite a long time I think it's for one and a half year now But some of you might think that is not necessary if We have resting core. Okay. Oh now let's get to internal things Oh, so what is it in terms of things internal things is basically network of some physical object which we have some sensor software and network connection and They can collect and exchange data Maybe it's for someone on field this For me when I was starting my hobby project I came with idea that you should have Drupal marketplace or Normally commerce solution where you buy products and then you come to the smart box which is run on Drupal 8 as well and you pick the data or pick the product you ordered I started this like half a year ago Oh It was time when Raspberry announced the five pound model and I was quite curious if Drupal will be able to run on this It seems that it should be possible but because on this five dollar Model there are there is a network connection by default I chose more advanced model But I will get to the hardware part So what were challenges These were biggest challenges the first is authentication then I have to overwrite Drupal rest in core and The last one was hardware and issues connection to hardware. So the first Is authentication as I mentioned You probably don't want everybody to access your data or because you are storing Personal information Also, and so also when you come to this Pickup terminals you don't want to type your email address and your password if you have So to face authentication you need to write also some pin code there. So it wouldn't be very user-friendly so I picked own phone and phone number and Pin authentication on this quite common in in Slovakia very Health some solutions running this way For these I need to write my own authentication provider It's quite simple task because you can generate all this code with Drupal console and You need to implement These two methods on the first method applies Which basically is very basically describe If your authentication Provider should be applied for this request and the other is authenticate method where you Find out if user out on if user is Authenticate to access the data So basically in my case I I Get the number from a header. I get pin from header if They are in header HTTP header I Apply this authentication provider and then I Find out if user Enter these data correctly Okay, the other challenge was Drupal REST. So as I said that You have something in the core on there is also wheels REST output in the core But as I said before you don't have version the API This was quite a big problem because You are developing the application constantly you need to do some changes and You probably don't want to shut down all All your subcribers of the API So I Created some on REST and points or part of them were created in the views where you can pick Fields you want to apply filter criteria for them like basically you are creating normal view display or what is the problem is that You can't set Any access control You need to override it in the code add for the root Some Requirements and then set it back. It should look something like this. There is issue for it And it need work. So if you will go sprint after these you should work also on this Okay, oh, let's get to our custom end points. You can again easily generate it. It will generate some kind of this code or If you generate for multiple request types they will be here and You will have a separate method for Each request type. So if you choose get post Delete or you will have three methods In this class and you will just put your custom logic inside After you create them those you need to enable These end points or you can do it via code in the ammo file where you type resource name then all these request types and your name which which formats are supported and Which authentication is supported for for these formats or You can do it or using rescue I module where you basically get list of resources and then you just check What do you want? What do what do you want to support? And the last Challenge was hardware as I mentioned earlier this project started when Raspberry 5 5 dollar module model was released. I Picked the stronger one. This is B plus model. I think I Basically, you you can install Standard Almost standard They be on on it and then install full lampstick on it I think there are better solutions for this for example some Docker containers optimized for this or there is Uncivil script, which is able to install all for you Oh, but this was just a hobby project. So I didn't spend too much time on the hardware part You may see that it's just Drupal on one way Drupal on the other way or communicating Oh, and there are basically no sensors, but I think that you can In this case, you can fetch some data or for example when was some kind of project picked up and then e-commerce can use this data for stock Okay, so In the end what what are lessons learned from this project? I think that the coupling with Internet of Things is quite viable concept and The other things Thing I learned is that Drupal rest Needs quite a lot of improvements to be useful So if you are going to spring you can spring awesome press issues as well Thank you for your attention and to have any questions Also, the question was about a big pipe and front end frameworks. Oh, I I'm not really sure if If it is something outside Drupal world because this is a solution that you can use Drupal 8 without any front like front end frameworks do the coupling and still will get some of the benefits of the coupling Oh, I used the core as module and custom endpoints. Okay, so if there are no other questions Thank you and so give me feedback, please