Skip to content

Examples

fredthedoggy edited this page Mar 29, 2021 · 2 revisions

Example Usage of RestPlaceholderAPI in an External Application.

NodeJS:

var http = require('http');

var options = {
    host : 'example.com',
    port : PORT,
    path : '/226d5055-3e41-44f4-a527-ecbce4a6bb28/player_online',
    headers : {
       'token' : 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
    }
    method : 'GET'
};

var request = http.request(options, function(res) {
    res.on('data', function(data) {
        console.log(data)
    });
});
request.end();
request.on('error', function(error) {
    console.error(error);
});

Python:

import requests

x = requests.get("http://example.com:PORT/" + "226d5055-3e41-44f4-a527-ecbce4a6bb28" + "/player_online", headers={"token":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})

print(x.text)