REST_CLIENT module
Admin Guide
Section titled “Admin Guide”Overview
Section titled “Overview”The rest_client module provides a means of interacting with an HTTP server by doing RESTful queries, such as GET and POST.
Dependencies
Section titled “Dependencies”OpenSIPS Modules
Section titled “OpenSIPS Modules”The following modules must be loaded before this module:
- No dependencies on other OpenSIPS modules..
External Libraries or Applications
Section titled “External Libraries or Applications”The following libraries or applications must be installed before running OpenSIPS with this module loaded:
- libcurl.
Exported Parameters
Section titled “Exported Parameters”connection_timeout (integer)
Section titled “connection_timeout (integer)”Maximum time allowed to establish a connection with the server.
Default value is “20” seconds.
...modparam("rest_client", "connection_timeout", 300)...curl_timeout (integer)
Section titled “curl_timeout (integer)”Maximum time allowed for the libcurl transfer to complete.
Default value is “20” seconds.
...modparam("rest_client", "curl_timeout", 300)...ssl_verifypeer (integer)
Section titled “ssl_verifypeer (integer)”Set this to 0 in order to disable the verification of the remote peer’s certificate. Verification is done using a default bundle of CA certificates which come with libcurl.
Default value is “1” (enabled).
...modparam("rest_client", "ssl_verifypeer", 0)...ssl_verifyhost (integer)
Section titled “ssl_verifyhost (integer)”Set this to 0 in order to disable the verification that the remote peer actually corresponds to the server listed in the certificate.
Default value is “1” (enabled).
...modparam("rest_client", "ssl_verifyhost", 0)...ssl_capath (integer)
Section titled “ssl_capath (integer)”An optional path for CA certificates to be used for host verifications.
...modparam("rest_client", "ssl_capath", "/home/opensips/ca_certificates")...Exported Functions
Section titled “Exported Functions”rest_get(url, body_pv[, ctype_pv[, retcode_pv]])
Section titled “rest_get(url, body_pv[, ctype_pv[, retcode_pv]])”Issues an HTTP GET request to the given ‘url’, and returns a representation of the resource.
The body_pv pseudo-var will hold the body of the HTTP response.
The optional ctype_pv pseudo-var will contain the value of the “Content-Type:” header.
The optional retcode_pv pseudo-var is used to retain the HTTP status code of the response message.
Possible parameter types
- url - String, pseudo-variable, or a String which includes pseudo-variables. (useful for specifying additional attribute-value fields in the URL)
- body_pv, ctype_pv, retcode_pv - pseudo-variables
This function can be used from the startup, branch, failure, request and timer routes.
...# Example of querying a REST service to get the credit of an account
if (!rest_get("http://getcredit.org/?ruri=$fU", "$var(credit)", "$var(ct)", "$var(rcode)")) { xlog("Error code $var(rcode) in HTTP GET!\n"); send_reply("403", "Not registered"); exit;}...rest_post(url, send_body_pv, send_ctype_pv, recv_body_pv[, recv_ctype_pv[, retcode_pv]])
Section titled “rest_post(url, send_body_pv, send_ctype_pv, recv_body_pv[, recv_ctype_pv[, retcode_pv]])”Issues an HTTP POST request to the specified ‘url’. The request body will be copied from the ‘send_body_pv’ pseudo-variable. Its MIME content type will be taken from ‘send_ctype_pv’.
The recv_body_pv pseudo-var will hold the body of the HTTP response.
The optional recv_ctype_pv parameter will contain the value of the “Content-Type:” header of the response message.
The optional retcode_pv pseudo-var parameter can be given in order to save the HTTP status code of the response message.
Possible parameter types
- url, send_body_pv, send_type_pv - String, pseudo-variable, or a String which includes pseudo-variables.
- recv_body_pv, recv_ctype_pv, retcode_pv - pseudo-variables
This function can be used from the startup, branch, failure, request and timer routes.
...# Storing data using a RESTful service with an HTTP POST request
if (!rest_post("http://myserver.org/register_user", "$fU", "text/plain", "$var(body)", "$var(ct)", "$var(rcode)")) { xlog("Error code $var(rcode) in HTTP POST!\n"); send_reply("403", "POST Forbidden"); exit;}...Contributors
Section titled “Contributors”By Commit Statistics
Section titled “By Commit Statistics”Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)
| # | Name | DevScore | Commits | Lines++ | Lines— |
|---|---|---|---|---|---|
| 1. | Liviu Chircu (@liviuchircu) | 22 | 10 | 1074 | 76 |
| 2. | Stefan Darius (@dariusstefan) | 7 | 3 | 246 | 28 |
| 3. | Jarrod Baumann (@jarrodb) | 3 | 1 | 27 | 26 |
| 4. | Razvan Crainea (@razvancrainea) | 3 | 1 | 1 | 1 |
| 5. | Andrey Vorobiev (@andrey-vorobiev) | 2 | 1 | 2 | 0 |
(1) DevScore = author_commits + author_lines_added / (project_lines_added / project_commits) + author_lines_deleted / (project_lines_deleted / project_commits)
(2) including any documentation-related commits, excluding merge commits
(3) ignoring whitespace edits, renamed files and auto-generated files
By Commit Activity
Section titled “By Commit Activity”| # | Name | Commit Activity |
|---|---|---|
| 1. | Stefan Darius (@dariusstefan) | Jun 2026 - Jul 2026 |
| 2. | Razvan Crainea (@razvancrainea) | Jun 2026 - Jun 2026 |
| 3. | Andrey Vorobiev (@andrey-vorobiev) | Feb 2017 - Feb 2017 |
| 4. | Liviu Chircu (@liviuchircu) | Mar 2013 - Dec 2016 |
| 5. | Jarrod Baumann (@jarrodb) | Apr 2015 - Apr 2015 |
(1) including any documentation-related commits, excluding merge commits
Documentation
Section titled “Documentation”Contributors
Section titled “Contributors”Last edited by: Razvan Crainea (@razvancrainea), Liviu Chircu (@liviuchircu).
License
Section titled “License”All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0