Skip to main content

overwolf.web API

Use this API to open a local HTTP web-server and a WebSocket.

Methods Reference

Types Reference

createServer(port, callback)

Version added: 0.93

Permissions required: Web

Creates a web server.

ParameterTypeDescription
portintThe port to use
callbackCreateServerResult ObjectContainer for the server object

Usage Example

Here you can see a sample code for using the overwolf.web and overwolf.web.webserver APIs:

let _port = 61234;

overwolf.web.createServer(_port, serverInfo => {
if (serverInfo.status == "error") {
console.log("Failed to create server");
return;
} else {
_server = serverInfo.server;
// it is always good practice to removeListener before adding it
_server.onRequest.removeListener(onRequest);
_server.onRequest.addListener(onRequest);

_server.listen(info => {
console.log("Server listening status on port " + _port + " : " + info);
//info = { "status": "success", "url": "http://localhost:61234/"}
});
}
});

function onRequest(info) {
console.log(info.content);
// info = { "content": "{'hello': 'world'}", "contentType": "application/json", "url": "http://localhost:59873/"}
}

...

_server.close();

sendHttpRequest(url, method, headers, data, callback)

Version added: 0.126

Permissions required: Web

Send an https request (of different methods) to localhost/127.0.0.1 while by-passing a valid certificate verification.

ParameterTypeDescription
urlstring
methodHttpRequestMethods enum
headersFetchHeader[]an array of http headers (key,value) pairs. See notes below
datastring (Optional)The data being sent to the server (relevant for POST/PUT requests)
callbackSendHttpRequestResult ObjectContainer for the send requests

headers notes

An example of FetchHeader objects array: [{ key: "Content-Type", value: "application/json" }].

createWebSocket(connectionParams, callback)

Version added: 0.129

Permissions required: Web

Creates a WebSocket client to localhost/127.0.0.1.

ParameterTypeDescription
connectionParamsWebSocketConnectionParams Objectconnection params. See notes below
callbackCreateWebSocketResult ObjectA callback function which will be called with the status of the request

connectionParams notes

An example:

{
"secured":true,
"port": int,
"credentials": {
"username": "riot",
"password": "string" (e.g lcuCredentialsoverw.native_token)
},
"protocols":["wamp"]
}

WebSocketConnectionParams Object

Version added: 0.129

Container for the connection params.

ParameterTypeDescription
securedbool
portintThe port to use
credentialsLoginCredentials
protocolsstring[]

HttpRequestMethods enum

Version added: 0.129

HTTP requests methods.

OptionDescription
GET
HEAD
POST
PUT
DELETE
PATCH

FetchHeader Object

Version added: 0.126

Container for a key value pair that represent an HTTP header.

Read more about http headers here.

ParameterTypeDescription
keystring
valuestring

Object Data Example

{ "key": "Content-Type", "value": "application/json" }

MessageType enum

Version added: 0.129

Describes different types on messages.

OptionDescription
ping
binary
text

Example data: Success


CreateServerResult Object

ParameterTypeDescription
successbooleaninherited from the "Result" Object
errorstringinherited from the "Result" Object
serverWebServer object

Example data: Success

A callback function which returns the status of the request and an object with two fields: A status string and a server object.

{
"status": "success",
"server": {
"onRequest": {}
}
}

SendHttpRequestResult Object

ParameterTypeDescription
successbooleaninherited from the "Result" Object
errorstringinherited from the "Result" Object
statusCodenumber
datastring

Example data: Success

{ "status": "success" }

CreateWebSocketResult Object

ParameterTypeDescription
successbooleaninherited from the "Result" Object
errorstringinherited from the "Result" Object
clientWebSocket object

Example data: Success

This call returns a status and a WebSocket object.

{
"status": "success",
"client": "IOverwolfWebSocket"
}