rangarajan
rangarajan

Reputation: 191

How to integrate Django API with XMPP server (ejabberd)

I'm currently working on a project where I'm using Django rest framework (DRF) for the backend. I need to implement one to one chat on this application. For this, I'm using XMPP server. I'm using ejabberd as XMPP server.

Now, I need to create users in the ejabberd server using my API built with DRF. I need to achieve following things with my API:

The username will be fetched or retrived from the frontend. Is there any Python API client or Django API client to do this in the ejabberd server? Like how there is simple-xmpp for node js

I have seen many python packages for this. some of them are,

I'm not sure which one to use and I don't know whether is it possible to implement the above using any of these packages.

Upvotes: 0

Views: 527

Answers (1)

Badlop
Badlop

Reputation: 4120

All those libraries that you mention seem to be to write XMPP clients. In that case, you can write a small XMPP client that will attempt to register account in a xmpp server (being ejabberd or whatever), that joins a MUC room, configures it to be persistent, then requests the lists of rooms...

A completely different approach would be to call API commands that ejabberd provides. As you can see in the API documentation, there are commands to perform precisely what you want, and many more: register, create_room_with_opts, muc_online_rooms.

And how to call this API? For playing and checking what those commands do, you can use the ejabberdctl command-line script. Probably you will later want to use ReST (then configure mod_http_api) or XML-RPC (in that case configure ejabberd_xmlrpc). See Understanding ejabberd commands, and also check the example configuration and example calls using curl.

Upvotes: 1

Related Questions