SlideShare a Scribd company logo
RESTful Web Services
    in Drupal 7
RESTful Web Services in Drupal 7



‣ Web Services introduction
‣   Why REST?
‣   The Bricks: Drupal 7, Entity API, RESTful Web Services
‣   Connector (REST client)
‣   Let’s go coding...
‣   Case Study
‣   Questions?
Web services




                 SOAP,
  Service      XML-RPC,
                              Service
 Requester     REST, etc...   Provider
Web services with Drupal




                      REST
  Service                    Service
 Requester                   Provider
Why REST?


‣   Use standard HTTP (simple client and simple API)

‣   Multiple data formats (JSON, XML, etc...)

‣   Performance and scalability (Cacheable)
The bricks




   Connector   REST   RESTws

    Drupal 6
        or            Entity API
    Drupal 7
    Service           Drupal 7
   Requester
                      Service
                      Provider
Entity API

This module extends the entity API of Drupal
core in order to provide a unified way to
deal with entities and their properties.

Additionally, it provides an entity CRUD
controller, which helps simplifying the
creation of new entity types.

http://drupal.org/project/entity
RESTful Web Services
Exposes Drupal resources (e.g. entities) as RESTful web services.
‣ Provides only RESTful services.
‣ Builds upon the Entity API, to provide support for all entity types out of the
box.
‣ Currently only CRUD operations supported
‣ Currently JSON, XML and RDF/XML are available out of the box.
‣ There are no "service endpoints" to configure as resources are just available
at uniform paths like "node/1", "user/1".




http://drupal.org/project/restws
RESTful Web Services: Test it!


To obtain the JSON representation of an entity use your
browser to visit:

http://yoursite.com/node/1.json or
http://yoursite.com/user/1.json or
http://yoursite.com/<entity type name>/<entity id>.json
Note: The module will respect your access permissions, so make sure you are logged in.
RESTful Web Services: CRUD
Supports full CRUD (Create, Read, Update, Delete) for resources:
‣   Create: HTTP PUT /<entity type name>
    (requires HTTP Content-Type header set to the MIME type of <format>)
‣   Read: HTTP GET /<entity type name>/<entity id>.<format>
    or HTTP GET /<entity type name>/<entity id>
  (requires HTTP Accept header set to the MIME type of <format>)
‣ Update: HTTP POST /<entity type name>/<entity id>.<format>
 or HTTP POST /<entity type name>/<entity id>
  (requires HTTP Content-Type header set to the MIME type of the posted format)
‣ Delete: HTTP DELETE /<entity type name>/<entity id>


Note: The representation <format> can be json, xml etc.
RESTful Web Services: Auth and Perms

               can be achieved via separate modules, maybe making use of
‣ Authentication
the standard Drupal cookie and session handling.

‣ The module comes with an optional HTTP Basic Authentication module
(restws_auth_basic) that performs a user login with the credentials provided
via the usual HTTP headers.

‣ Theusual Drupal permission system is respected, thus permissions are
checked for the logged in user account of the received requests.
Connector: REST Client
Connector: Example (webform hook)
Connector: Example (response)
Case Study




                 REST

  Pamm Travel             Tikal
    (Drupal 6)          (Drupal 7)

    Service             Service
   Requester            Provider
Case Study




                 REST

    Intersos              Tikal
    (Drupal 6)          (Drupal 7)

    Service             Service
   Requester            Provider
Questions?
                          http://bmeme.com




   Luca Corbo (lucor)                          Daniele Piaggesi (g0blin)
luca.corbo@bmeme.com                         daniele.piaggesi@bmeme.com
       @lucacorbo                                      @g0blin79

More Related Content

Similar to RESTful Web Services in Drupal7 (20)

PDF
Services in Drupal 8
Andrei Jechiu
 
PDF
Drupal South 2015: Introduction to Web Services. Services in Drupal 8.
TechnocratAu
 
PPT
Drupal As A RESTful Backend For Client Side Applications
Myplanet Digital
 
PDF
[Srijan Wednesday Webinar] Decoupled Demystified: The Present & Future of Dr...
Srijan Technologies
 
PDF
Talking to Web Services
DrupalcampAtlanta2012
 
PPTX
REST in Peace
Kate Marshalkina
 
PPTX
Drupal 8 Deep Dive: What It Means for Developers Now that REST Is in Core
Acquia
 
PPTX
Decoupling Drupal 8.x: Drupal’s Web Services Today and Tomorrow
Acquia
 
PPTX
RESTful application with Drupal 8
Patrick Morin
 
PDF
With Drupal Your Website is an API
Charlie Morris
 
PPTX
Drupal 7 Web Services Crash Course
Noah Lively
 
PPTX
RestFul Web Services In Drupal 8
Gajendra Sharma
 
ODP
что нового в мире Services
DrupalCamp Kyiv Рысь
 
PDF
RESTful with Drupal - in-s and out-s
Kalin Chernev
 
PDF
Drupal 8 as a mobile backend
Alkuvoima
 
PDF
Services Drupalcamp Stockholm 2009
hugowetterberg
 
PDF
Drupal and communication
Peter Arato
 
PPTX
Oleg Bogut - Decoupled Drupal: how to build stable solution with JSON:API, Re...
DrupalCamp Kyiv
 
PDF
Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...
Vlad Savitsky
 
ODP
Services Stanford 2012
Yuriy Gerasimov
 
Services in Drupal 8
Andrei Jechiu
 
Drupal South 2015: Introduction to Web Services. Services in Drupal 8.
TechnocratAu
 
Drupal As A RESTful Backend For Client Side Applications
Myplanet Digital
 
[Srijan Wednesday Webinar] Decoupled Demystified: The Present & Future of Dr...
Srijan Technologies
 
Talking to Web Services
DrupalcampAtlanta2012
 
REST in Peace
Kate Marshalkina
 
Drupal 8 Deep Dive: What It Means for Developers Now that REST Is in Core
Acquia
 
Decoupling Drupal 8.x: Drupal’s Web Services Today and Tomorrow
Acquia
 
RESTful application with Drupal 8
Patrick Morin
 
With Drupal Your Website is an API
Charlie Morris
 
Drupal 7 Web Services Crash Course
Noah Lively
 
RestFul Web Services In Drupal 8
Gajendra Sharma
 
что нового в мире Services
DrupalCamp Kyiv Рысь
 
RESTful with Drupal - in-s and out-s
Kalin Chernev
 
Drupal 8 as a mobile backend
Alkuvoima
 
Services Drupalcamp Stockholm 2009
hugowetterberg
 
Drupal and communication
Peter Arato
 
Oleg Bogut - Decoupled Drupal: how to build stable solution with JSON:API, Re...
DrupalCamp Kyiv
 
Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...
Vlad Savitsky
 
Services Stanford 2012
Yuriy Gerasimov
 

More from bmeme (7)

PDF
Speed up your Drupal instance!!
bmeme
 
PPTX
Drupal 4 stakeholder
bmeme
 
PDF
"Twig e i belli dentro": panoramica sui nuovi standard di frontend-developmen...
bmeme
 
PDF
Sviluppo Code-driven e riusabilità del codice: CMI e Features per D8
bmeme
 
PDF
La piattaforma web di CNA: Istanze Drupal replicabili integrate con Alfresco ...
bmeme
 
PDF
"Eventum project" - A Drupal platform for managing events and conferences
bmeme
 
PDF
Features in love
bmeme
 
Speed up your Drupal instance!!
bmeme
 
Drupal 4 stakeholder
bmeme
 
"Twig e i belli dentro": panoramica sui nuovi standard di frontend-developmen...
bmeme
 
Sviluppo Code-driven e riusabilità del codice: CMI e Features per D8
bmeme
 
La piattaforma web di CNA: Istanze Drupal replicabili integrate con Alfresco ...
bmeme
 
"Eventum project" - A Drupal platform for managing events and conferences
bmeme
 
Features in love
bmeme
 
Ad

Recently uploaded (20)

PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Advancing WebDriver BiDi support in WebKit
Igalia
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Advancing WebDriver BiDi support in WebKit
Igalia
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Ad

RESTful Web Services in Drupal7

  • 1. RESTful Web Services in Drupal 7
  • 2. RESTful Web Services in Drupal 7 ‣ Web Services introduction ‣ Why REST? ‣ The Bricks: Drupal 7, Entity API, RESTful Web Services ‣ Connector (REST client) ‣ Let’s go coding... ‣ Case Study ‣ Questions?
  • 3. Web services SOAP, Service XML-RPC, Service Requester REST, etc... Provider
  • 4. Web services with Drupal REST Service Service Requester Provider
  • 5. Why REST? ‣ Use standard HTTP (simple client and simple API) ‣ Multiple data formats (JSON, XML, etc...) ‣ Performance and scalability (Cacheable)
  • 6. The bricks Connector REST RESTws Drupal 6 or Entity API Drupal 7 Service Drupal 7 Requester Service Provider
  • 7. Entity API This module extends the entity API of Drupal core in order to provide a unified way to deal with entities and their properties. Additionally, it provides an entity CRUD controller, which helps simplifying the creation of new entity types. http://drupal.org/project/entity
  • 8. RESTful Web Services Exposes Drupal resources (e.g. entities) as RESTful web services. ‣ Provides only RESTful services. ‣ Builds upon the Entity API, to provide support for all entity types out of the box. ‣ Currently only CRUD operations supported ‣ Currently JSON, XML and RDF/XML are available out of the box. ‣ There are no "service endpoints" to configure as resources are just available at uniform paths like "node/1", "user/1". http://drupal.org/project/restws
  • 9. RESTful Web Services: Test it! To obtain the JSON representation of an entity use your browser to visit: http://yoursite.com/node/1.json or http://yoursite.com/user/1.json or http://yoursite.com/<entity type name>/<entity id>.json Note: The module will respect your access permissions, so make sure you are logged in.
  • 10. RESTful Web Services: CRUD Supports full CRUD (Create, Read, Update, Delete) for resources: ‣ Create: HTTP PUT /<entity type name> (requires HTTP Content-Type header set to the MIME type of <format>) ‣ Read: HTTP GET /<entity type name>/<entity id>.<format> or HTTP GET /<entity type name>/<entity id> (requires HTTP Accept header set to the MIME type of <format>) ‣ Update: HTTP POST /<entity type name>/<entity id>.<format> or HTTP POST /<entity type name>/<entity id> (requires HTTP Content-Type header set to the MIME type of the posted format) ‣ Delete: HTTP DELETE /<entity type name>/<entity id> Note: The representation <format> can be json, xml etc.
  • 11. RESTful Web Services: Auth and Perms can be achieved via separate modules, maybe making use of ‣ Authentication the standard Drupal cookie and session handling. ‣ The module comes with an optional HTTP Basic Authentication module (restws_auth_basic) that performs a user login with the credentials provided via the usual HTTP headers. ‣ Theusual Drupal permission system is respected, thus permissions are checked for the logged in user account of the received requests.
  • 15. Case Study REST Pamm Travel Tikal (Drupal 6) (Drupal 7) Service Service Requester Provider
  • 16. Case Study REST Intersos Tikal (Drupal 6) (Drupal 7) Service Service Requester Provider
  • 17. Questions? http://bmeme.com Luca Corbo (lucor) Daniele Piaggesi (g0blin) [email protected] [email protected] @lucacorbo @g0blin79