Skip to content

JSON RPC API

Valerie Pond edited this page Aug 22, 2022 · 12 revisions

JSON-RPC 2.0

Dalek IRC Services ships with a JSON-RPC API. This follows the JSON-RPC 2.0 specification.

Interfacing

This, at the moment, is only done locally on port 1024, using POST method to send JSON requests (like in the below examples).

Calls must be made to the /api endpoint.

Examples:

Example one: Getting information

An example call to get the MD for user Valware:

curl -s --insecure -X POST -d '{"jsonrpc": "2.0", "method": "md.get", "params": {"user": "Valware"}, "id": 123}' http://localhost:1024/api

which returns something like:

{
    "jsonrpc": "2.0",
    "result": {
        "operclass": "netadmin",
        "operlogin": "Valware",
        "creationtime": "1661022098",
        "certfp": "8e8fb90324550d3a379c75c50e9e3cd52e1e21723532eaa4b85b61dc84f48e7e",
        "tls_cipher": "TLSv1.3-TLS_CHACHA20_POLY1305_SHA256",
        "geoip": "cc=FR|cd=France"
    },
    "id": 123
}

Example two: Executing remote procedures

An example of how to forcefully login a user who is on IRC

curl -s --insecure -X POST -d '{"jsonrpc": "2.0", "method": "operserv.forcelogin", "params": {"user": "Valware", "account": "Valware"}, "id": 123}' http://localhost:1024/api

will return something like:

{
    "jsonrpc": "2.0",
    "result": "User \"Valware\" logged into account \"Valware\" successfully.",
    "id": 123
}

Notes

  • Your RPC request must contain "jsonrpc": "2.0", otherwise it will not be valid.
  • You must specify an id. This can be random, however the reply will reflect the ID so you can be sure the response is for what you requested.
  • The method must be a valid Dalek RPC method as documented below or added by a third-party module.
  • The result field in the response JSON object will contain the result of your request.

Built-In RPC method names and their parameters

Work in Progress

The list below shows methods currently implemented. Things are still being implemented, so hold tight.

Name Params Param Description Return
module.load module The directory and name of the module, e.g; third/os_raw (the same as the loadmodule() command in modules.conf) result on success, error on failure.
module.unload module The name of the module, e.g; os_raw to unload.
module.list None None result containing a list of modules and their information.
chg.host user, host user must be the nick or UID of a valid user on IRC. host must be a valid hostmask result on success, error on failure.
chg.ident user, ident user must be the nick or UID of a valid user on IRC. ident must be a valid ident result on success, error on failure.
chg.name user, name user must be the nick or UID of a valid user on IRC. name must be a valid Real Name/GECOS result on success, error on failure.
md.get user user must be the nick or UID of a valid user on IRC result containing a list of MD
operserv.forcelogin user, account user must be the nick or UID of a valid user on IRC. account must be a valid WordPress account linked to your IRC. result on success, error on failure.
user.get nick user must be the nick or UID of a valid user on IRC.` result on success, error on failure.
user.list None None result containing a list of nicks and relative information
channel.get channel channel must be a valid channel that exists on IRC. result on success, error on failure
channel.list None None `result containing a list of channels and relative information.

Error codes

You may receive error codes

Clone this wiki locally