Openfire chat history

Is there a way I can retrieve the chat room history?

I mean is there any api for it?

I have an app which provides chat support through openfire but I want to provide a way for the users to see the chat history as well.

Any solution is very much appreciated