Web services proof-of-concept code

480 views
Skip to first unread message

Chris Davenport

unread,
Mar 26, 2013, 1:15:02 PM3/26/13
to Joomla! CMS Development
I have recently been tinkering with a proof-of-concept for web services in the Joomla 3.x series based on the draft specification for web services that I've been working on since last November.  The code is available from GitHub here: https://github.com/chrisdavenport/j3-rest-api  Alternatively, Matias Aguirre has kindly merged the API code into the CMS code so you might prefer to clone from that instead: https://github.com/fastslack/joomla-cms (Thanks Matias).

The best way to get a feel for what it can do is to install Mike Kelly's HAL Browser (https://github.com/mikekelly/hal-browser) on your system and point it to your /api directory (instructions are given in the README.md).  This allows you to interactively explore the API with full visibility of requests and responses.

At present there is support for GET requests only for articles, weblinks, menu items and categories.

Third-party extension developers may like to note that no core code was harmed in the making of this API.

This is a long way from being finished, but I would appreciate feedback, especially on architecture.

Thanks,
Chris.

--
Chris Davenport
Joomla Production Leadership Team

Nick Savov

unread,
Apr 1, 2013, 6:08:21 PM4/1/13
to joomla-...@googlegroups.com
This is fantastic, Chris!  Nice job on it!

I started doing some of the API lessons at Codecademy (http://www.codecademy.com/tracks/apis) to get up to speed on API and web services.  For those of us who aren't code savvy, could you create a quick introduction video to what you have so far?  It would be a good way to spread the word about what you're doing and to gain more support for it.

Kind regards,
Nick

Chris Davenport

unread,
Apr 1, 2013, 7:47:25 PM4/1/13
to Joomla! CMS Development
Good idea.  I'll see if I can put something together.

Did you manage to get the HAL Browser working?  That's a great way to explore the API (well, the small part of it that has been implemented so far) without needing to understand the code.

All the best,
Chris.



--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cm...@googlegroups.com.
To post to this group, send an email to joomla-...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Chris Davenport

unread,
Apr 2, 2013, 4:55:32 AM4/2/13
to Joomla! CMS Development
Thank you, Amy.  I was aiming for elegant, but I'll settle for beautiful. :P

Chris.


On 2 April 2013 05:14, Amy Stephen <amyst...@gmail.com> wrote:
Chris - your code is beautiful.


--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cm...@googlegroups.com.
To post to this group, send an email to joomla-...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.


Chris Davenport

unread,
Apr 3, 2013, 7:40:03 PM4/3/13
to Joomla! CMS Development
I have now set up a live demo of the proof-of-concept web services code.  It is a stock Joomla 3.0 site with the test sample data and the API code added.

API entry point: http://demo.davenporttechnology.com/api/

I would recommend exploring it using the HAL Browser by pointing your web browser at: http://demo.davenporttechnology.com/api/hal-browser/browser.html#/api

Bear in mind that not everything works at this point in time.

Have fun.

Chris.



On 2 April 2013 13:05, Amy Stephen <amyst...@gmail.com> wrote:
Might just be one of those en-gb vs en-us things.

Well done.

elin

unread,
Apr 4, 2013, 12:10:23 AM4/4/13
to joomla-...@googlegroups.com
For people who are interested in services, we have two and possibly three (depending on approach) GSoC project ideas that are services focused.  We really need mentors and  co-mentors who would be interested in working with a student on any of these.   


Of course we'd like mentors for other potential projects also.  We try to have at least 2 per student.

Elin

piotr_cz

unread,
Apr 5, 2013, 8:22:52 AM4/5/13
to Joomla! CMS Development
Please setup CORS on demo server,
cannot use HAL Browser because `Origin http://localhost is not allowed
by Access-Control-Allow-Origin.`

info: https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS


On Apr 4, 1:40 am, Chris Davenport <chris.davenp...@joomla.org> wrote:
> I have now set up a live demo of the proof-of-concept web services code.
> It is a stock Joomla 3.0 site with the test sample data and the API code
> added.
>
> API entry point:http://demo.davenporttechnology.com/api/
>
> I would recommend exploring it using the HAL Browser by pointing your web
> browser at:http://demo.davenporttechnology.com/api/hal-browser/browser.html#/api
>
> Bear in mind that not everything works at this point in time.
>
> Have fun.
>
> Chris.
>
> On 2 April 2013 13:05, Amy Stephen <amystep...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > Might just be one of those en-gb vs en-us things.
>
> > Well done.
>
> > On Tuesday, April 2, 2013 3:55:32 AM UTC-5, Chris Davenport wrote:
>
> >> Thank you, Amy.  I was aiming for elegant, but I'll settle for beautiful.
> >> :P
>
> >> Chris.
>
> >> On 2 April 2013 05:14, Amy Stephen <amyst...@gmail.com> wrote:
>
> >>> Chris - your code is beautiful.
>
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "Joomla! CMS Development" group.
> >>> To unsubscribe from this group and stop receiving emails from it, send
> >>> an email to joomla-dev-cm...@**googlegroups.com.
> >>> To post to this group, send an email to joomla-...@googlegroups.**com.
>
> >>> Visit this group athttp://groups.google.com/**
> >>> group/joomla-dev-cms?hl=en-GB<http://groups.google.com/group/joomla-dev-cms?hl=en-GB>
> >>> .
> >>> For more options, visithttps://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
> >>> .
>
> >> --
> >> Chris Davenport
> >> Joomla Production Leadership Team
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Joomla! CMS Development" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to joomla-dev-cm...@googlegroups.com.
> > To post to this group, send an email to joomla-...@googlegroups.com.
> > Visit this group athttp://groups.google.com/group/joomla-dev-cms?hl=en-GB
> > .
> > For more options, visithttps://groups.google.com/groups/opt_out.

Chris Davenport

unread,
Apr 5, 2013, 3:43:18 PM4/5/13
to Joomla! CMS Development
I have added
Access-Control-Allow-Origin: *

so it should work okay now.

Thanks for reporting the issue.

Chris.



For more options, visit https://groups.google.com/groups/opt_out.


piotr_cz

unread,
Apr 10, 2013, 4:33:45 AM4/10/13
to Joomla! CMS Development
Hi Chris,
the feature looks great so far.

I've been thinking about web services in Joomla for some time: I'd
like to use Joomla! as data provider and do the rendering client-side.

Do you have any plans in including other JDocument renderers output
besides component (head, message, module)?

- Module: Some pages (menu items) have assigned modules which could be
retrieved along
- Head: Sometimes there are additional scripts or stylesheets added
along which could be loaded on the clientside (Form validator, etc).
- Message: We need a (JSON) data format for system messages.


On Mar 26, 7:15 pm, Chris Davenport <chris.davenp...@joomla.org>
wrote:
> I have recently been tinkering with a proof-of-concept for web services in
> the Joomla 3.x series based on the draft specification for web services
> that I've been working on since last November.  The code is available from
> GitHub here:https://github.com/chrisdavenport/j3-rest-api Alternatively,
> Matias Aguirre has kindly merged the API code into the CMS code so you
> might prefer to clone from that instead:https://github.com/fastslack/joomla-cms(Thanks Matias).

Nick Savov

unread,
Apr 13, 2013, 1:10:51 PM4/13/13
to joomla-...@googlegroups.com
Hi Chris,

No, I haven't started working on the HAL Browser yet. I'll hopefully give
it a try as soon as things slow down a bit with some other tasks :)

Kind regards,
Nick

> Good idea. I'll see if I can put something together.
>
> Did you manage to get the HAL Browser working? That's a great way to
> explore the API (well, the small part of it that has been implemented so
> far) without needing to understand the code.
>
> All the best,
> Chris.
>
>
>
> On 1 April 2013 23:08, Nick Savov <ni...@iowawebcompany.com> wrote:
>
>> This is fantastic, Chris! Nice job on it!
>>
>> I started doing some of the API lessons at Codecademy (
>> http://www.codecademy.com/tracks/apis) to get up to speed on API and web
>> services. For those of us who aren't code savvy, could you create a
>> quick
>> introduction video to what you have so far? It would be a good way to
>> spread the word about what you're doing and to gain more support for it.
>>
>> Kind regards,
>> Nick
>>
>>
>> On Tuesday, March 26, 2013 12:15:02 PM UTC-5, Chris Davenport wrote:
>>>
>>> I have recently been tinkering with a proof-of-concept for web services
>>> in the Joomla 3.x series based on the draft specification for web
>>> services
>>> that I've been working on since last November. The code is available
>>> from
>>> GitHub here:
>>> https://github.com/**chrisdavenport/j3-rest-api<https://github.com/chrisdavenport/j3-rest-api>
>>> Alternatively, Matias Aguirre has kindly merged the API code into the
>>> CMS
>>> code so you might prefer to clone from that instead:
>>> https://github.com/fastslack/**joomla-cms<https://github.com/fastslack/joomla-cms>(Thanks
>>> Matias).
>>>
>>> The best way to get a feel for what it can do is to install Mike
>>> Kelly's
>>> HAL Browser
>>> (https://github.com/mikekelly/**hal-browser<https://github.com/mikekelly/hal-browser>)

Chris Davenport

unread,
Apr 14, 2013, 6:23:34 AM4/14/13
to Joomla! CMS Development
Hi Piotr,

Sorry for the delay in responding.  Got a bit behind on my emails. :-(

There are certainly opportunities to change the way parts of a web page are rendered when you have a services platform on which to build.  In templates you could replace jdoc:include statements for the module, modules and component types with Ajax web service calls, for example.  And I'll definitely be looking at adding a service facility to modules that will be similar to the service facility I added to components.

We could also add a new jdoc:include type="service" renderer which would take the service URL as an argument and pass the raw data returned by the service through some new module chrome functions which would handle the rendering.  Or you could create new services that pre-render the data for you (since services can be hierarchical, creating composite services like that should be straightforward).  I will certainly be looking at creating a new "service" extension type so that 3PDs and others can add new services to a site using the regular extension installer.

If you are building a page dynamically using web services then you will almost certainly want to call the "menuitems" service at some point, with the Itemid of the "page" you are rendering.  This will return an array of modules that are assigned to that page (it doesn't at the moment, but it will).  You will then make service calls to each of those modules.  There are several ways in which this can be handled depending on whether the service calls are made client-side or server-side and I want to give developers and site builders plenty of flexibility in choosing how to put the pieces together.  I might also create a new "pages" service that would help break the dependency on Itemid.

Not sure it would ever really make sense to replace the head renderer, but perhaps I've misunderstood what you were asking there.

The specification covers error (and other status) messages to some extent, although I think there are improvements that could be made.  Since the client could be making multiple service calls to construct a single page, there is no longer a single "application message queue" to render in the client.  Rather the client will need to consider messages returned by service calls and decide what to do with them (whether to aggregate them or deal with them separately, for example).

The services-first philosophy changes your whole way of thinking about how web pages are put together and I certainly don't have all the answers, but I hope that gives you a better picture of what I have in mind at the moment.

All the best,
Chris.


--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cm...@googlegroups.com.
To post to this group, send an email to joomla-...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.


Reply all
Reply to author
Forward
0 new messages