Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Perl modules are good for writing a RESTful web API client?

Tags:

rest

module

perl

I am going to be writing an application that does a bit of computation on data it gets from a RESTful web service and outputs to a text file and/or HTML page. The web service is XML over HTTP. I have done a simple proof of concept with LWP::Simple and XML::Simple, but it's all a bit ad-hoc.

Can anyone recommend some Perl modules or best practice for interacting with RESTful web services in this way? Is there one module that will take care of all the details for me (making request + handling response) or is the problem domain too general for that?

Note the web service is all XML over HTTP, though I expect to have to use HTTP GET, POST and HEAD eventually. I think I have the option of requesting JSON instead of XML if it makes thins simpler.

Thanks in advance.

like image 881
Anon Gordon Avatar asked Mar 22 '09 00:03

Anon Gordon


People also ask

What are the 4 most common REST API operations?

These operations stand for four possible actions, known as CRUD: Create, Read, Update and Delete. The server sends the data to the client in one of the following formats: HTML. JSON (which is the most common one thanks to its independence of computer languages and accessibility by humans and machines)

What is the most popular format used in REST Web services and API?

REST stands for Representational State Transfer. It is a software architecture style that relies on a stateless communications protocol, most commonly, HTTP. REST structures data in XML, YAML, or any other format that is machine-readable, but usually JSON is most widely used.

What is the most common protocol used for REST APIs?

REST is web standards based architecture and uses HTTP Protocol. It revolves around resource where every component is a resource and a resource is accessed by a common interface using HTTP standard methods.


2 Answers

I do most everything either with LWP::Simple, LWP::UserAgent, Mojo::UserAgent or WWW::Mechanize. The REST stuff is just choosing the right URL to send the request too. Once you get the response, there are plenty of modules on CPAN to handle XML or JSON. I particularly like Mojo since it comes with its own JSON and DOM parsers and tools.

like image 99
brian d foy Avatar answered Nov 15 '22 19:11

brian d foy


REST::Client is nice. Atlassian has a Writing a REST Client in Perl article.

like image 23
Phluks Avatar answered Nov 15 '22 19:11

Phluks