RESTful with Drupal 
Easy and consistent data management 
presentation by Kalin Chernev
Agenda 
● What is REST? 
● 3 reasons to build and use RESTful APIs 
● Data management paradigm reminded 
● Data managed by Drupal 
● Data managed by a friend of Drupal 
● Considerations 
● Modules and tools 
● Resources
About 
● Drupalist from 2007 
● Trainer 
● Web developer
What is REST 
Architectural style describes six constraints 
- Uniform Interface 
- Stateless 
- Cacheable 
- Client-Server 
- Layered System 
- Code on Demand (optional)
Simple and consistent way 
to manage data
Any device
Any technology 
Any technology stack which works via HTTP 
Name your server language: 
Python, Ruby, Java, NodeJS, PHP, .NET ...
Exchanging json files
Request / Response
Terminology to get you started 
● Resource URI 
● Endpoint 
● JSON 
● REST client 
● REST server
Remember? 
Data management at all CMS systems, boils 
down to simple: 
C R U D
CASE 1: Drupal is REST Server 
● We POST/GET jsons to manage Drupal 
● Data is managed in Drupal
Playing with the CRUD methods 
Endpoint Action Method 
/api/node CREATE POST 
/api/node VIEW ALL GET 
/api/:node_id VIEW SINGLE GET 
/api/:node_id UPDATE PUT 
/api/:node_id DELETE DELETE
In reality, one can almost 
always go a long way only 
using GET & POST
CASE 2: Drupal is REST Client 
● We POST/GET jsons to manage content 
outside Drupal 
● Data is contained outside Drupal 
Data is shown and managed in Drupal
Drops REST API Server 
Endpoint Action Method 
/drops CREATE POST 
/drops VIEW ALL GET 
/drops/:drop_id VIEW SINGLE GET 
/drops/:drop_id UPDATE PUT 
/drops/:drop_id DELETE DELETE
Drupal magic 
● hook_menu 
● hook_theme 
● helpers and callbacks
What do you get 
● Consistency and standardization 
● Separate responsibilities of development 
● Easy work 
● Core in D8 
● Cacheable 
● Predictable development (to most part)
Considerations 
● API server uptime and performance 
● Large amounts of data transfer 
● Security 
● Data validation 
● Error handling 
● Apache configurations to hide server 
address
Drupal contrib modules 
● Services (totally rewritten for D7, good API) 
● Services Entity API (of course!) 
● RESTClient (from my experience) 
● cURL HTTP Request (helper to restclient) 
● Self Documenting REST API (D8) 
● REST UI (D8)
Tools 
● Advanced REST Client 
● Rest Console 
● Postman 
i.e. You need a REST Client for your browser
Resources 
● www.restapitutorial.com 
● REST in Drupal 8 core 
● Build a RESTful API Using Node and 
Express 4 by scotch.io 
● The code of the presentation (managing 
drops in MEAN from Drupal back-end)

RESTful with Drupal - in-s and out-s

  • 1.
    RESTful with Drupal Easy and consistent data management presentation by Kalin Chernev
  • 2.
    Agenda ● Whatis REST? ● 3 reasons to build and use RESTful APIs ● Data management paradigm reminded ● Data managed by Drupal ● Data managed by a friend of Drupal ● Considerations ● Modules and tools ● Resources
  • 3.
    About ● Drupalistfrom 2007 ● Trainer ● Web developer
  • 4.
    What is REST Architectural style describes six constraints - Uniform Interface - Stateless - Cacheable - Client-Server - Layered System - Code on Demand (optional)
  • 5.
    Simple and consistentway to manage data
  • 6.
  • 7.
    Any technology Anytechnology stack which works via HTTP Name your server language: Python, Ruby, Java, NodeJS, PHP, .NET ...
  • 8.
  • 9.
  • 10.
    Terminology to getyou started ● Resource URI ● Endpoint ● JSON ● REST client ● REST server
  • 11.
    Remember? Data managementat all CMS systems, boils down to simple: C R U D
  • 12.
    CASE 1: Drupalis REST Server ● We POST/GET jsons to manage Drupal ● Data is managed in Drupal
  • 13.
    Playing with theCRUD methods Endpoint Action Method /api/node CREATE POST /api/node VIEW ALL GET /api/:node_id VIEW SINGLE GET /api/:node_id UPDATE PUT /api/:node_id DELETE DELETE
  • 14.
    In reality, onecan almost always go a long way only using GET & POST
  • 15.
    CASE 2: Drupalis REST Client ● We POST/GET jsons to manage content outside Drupal ● Data is contained outside Drupal Data is shown and managed in Drupal
  • 16.
    Drops REST APIServer Endpoint Action Method /drops CREATE POST /drops VIEW ALL GET /drops/:drop_id VIEW SINGLE GET /drops/:drop_id UPDATE PUT /drops/:drop_id DELETE DELETE
  • 17.
    Drupal magic ●hook_menu ● hook_theme ● helpers and callbacks
  • 18.
    What do youget ● Consistency and standardization ● Separate responsibilities of development ● Easy work ● Core in D8 ● Cacheable ● Predictable development (to most part)
  • 19.
    Considerations ● APIserver uptime and performance ● Large amounts of data transfer ● Security ● Data validation ● Error handling ● Apache configurations to hide server address
  • 20.
    Drupal contrib modules ● Services (totally rewritten for D7, good API) ● Services Entity API (of course!) ● RESTClient (from my experience) ● cURL HTTP Request (helper to restclient) ● Self Documenting REST API (D8) ● REST UI (D8)
  • 21.
    Tools ● AdvancedREST Client ● Rest Console ● Postman i.e. You need a REST Client for your browser
  • 22.
    Resources ● www.restapitutorial.com ● REST in Drupal 8 core ● Build a RESTful API Using Node and Express 4 by scotch.io ● The code of the presentation (managing drops in MEAN from Drupal back-end)