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).
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.