# HTTP/HTTPS Connection
Rostrum supports both HTTP and HTTPS connections. Enable HTTP with the `--http` switch, or HTTPS with the `--https` switch. HTTPS requires SSL certificate files to be provided. See [configuration document](configuration.md) for details on enabling these switches. See also [default ports](ports.md) for connection information.
## HTTP vs HTTPS
- **HTTP**: Plain text connections (use `--http`)
- **HTTPS**: Encrypted connections using SSL/TLS (use `--https`)
For production use, **HTTPS is strongly recommended** as it provides encryption and security for your API calls.
Requests are submitted as `POST` request, with the same request format as with other protocols as the body content.
## wget examples
### HTTP
```bash
wget --post-data='{"method": "server.ping", "params": []}' -q http://localhost:31400 -O -
{"id":0,"jsonrpc":"2.0","result":null}
```
### HTTPS
```bash
wget --post-data='{"method": "server.ping", "params": []}' -q --no-check-certificate https://localhost:61401 -O -
{"id":0,"jsonrpc":"2.0","result":null}
```
## Python examples
### HTTP
```python
import http.client
import json
conn = http.client.HTTPConnection("localhost", 31400)
data = {"method": "server.ping", "params": []}
conn.request("POST", "/", body=json.dumps(data))
response = conn.getresponse()
print(json.loads(response.read().decode()))
```
### HTTPS
```python
import http.client
import json
import ssl
# Create SSL context (for self-signed certificates)
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
conn = http.client.HTTPSConnection("localhost", 61401, context=ssl_context)
data = {"method": "server.ping", "params": []}
conn.request("POST", "/", body=json.dumps(data))
response = conn.getresponse()
print(json.loads(response.read().decode()))
```
# Node.js examples
### HTTP
```javascript
const http = require('http');
const data = JSON.stringify({ method: "server.ping", params: [] });
const options = {
hostname: 'localhost',
port: 31400,
method: 'POST',
headers: { 'Content-Type': 'application/json' },
};
http.request(options, (res) => {
res.setEncoding('utf8');
res.on('data', console.log);
}).on('error', console.error)
.end(data);
```
### HTTPS
```javascript
const https = require('https');
const data = JSON.stringify({ method: "server.ping", params: [] });
const options = {
hostname: 'localhost',
port: 61401,
method: 'POST',
headers: { 'Content-Type': 'application/json' },
// For self-signed certificates
rejectUnauthorized: false
};
https.request(options, (res) => {
res.setEncoding('utf8');
res.on('data', console.log);
}).on('error', console.error)
.end(data);
```