Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Good REST API Tutorial for Perl.

by perlfan (Vicar)
on Nov 02, 2020 at 16:39 UTC ( #11123349=note: print w/replies, xml ) Need Help??

in reply to Good REST API Tutorial for Perl.

A RESTful API is specific for HTTP* and utlizes the following characteristics of HTTP to provide implicit caller and handler semantics:
  • HTTP methods (GET, POST, PUT, DELETE, etc) - look up "CRUD" wrt "REST"
  • HTTP response codes
  • URL paths as entities and verbs
  • headers defining content type of request body and types of serialized output you will 'accept'

Among other things, the goal is to not have an explosion of endpoints and to specifically avoid explicit "remote" procedure calls via URL and query parameters.

I also recommend reading the Felding's thesis on REST or at least a break down of it.

In practical terms it boils down to using something as simple as HTTP::Tiny and paying very specific attention to the request method, endpoint URL, and payload (request body). You then take the response, it'll be taken as a combination of: HTTP Status (200, 404, etc), content type header, and request body (usually as serialized JSON or XML). The latter is what you're thinking might be JSON or XML, which you extract from the response object and then deserialize using something JSON::XS.

I can't stress enough the REST is specifically defined for HTTP. Its principles can be extended to other protocols, but it will not look the same (some have tried to apply REST to things like "web sockets", all have failed).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11123349]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2021-04-17 10:32 GMT
Find Nodes?
    Voting Booth?

    No recent polls found