Example requests - NodeJS

See the below 2 examples on how to use the Brid backend API using NodeJS without implementing our SDK.

GET request example

const axios = require('axios');

// Get your players list via the API using NodeJS

axios.get('https://api.brid.tv/apiv2/players/list/<SITE ID>/1.json', {
    headers: {
        "Authorization": "Bearer <YOUR AUTH CODE HERE>",
        "User-Agent": "Api | BridVideo",
        "X-Site": "<YOUR SITE/DOMAIN HERE>"
    }
   })
  .then(function (response) {
    // handle success
    console.log(response);
  })
  .catch(function (error) {
    // handle error
    console.log(error);
  })
  .then(function () {
    // always executed
  });

POST request example

const axios = require('axios');
const querystring = require('querystring');

// Add a video into Brid via the API using NodeJS

  axios({
    method: 'post',
    url: 'https://api.brid.tv/apiv2/videos/add/.json',
    data: querystring.stringify({
            'data[Video][partner_id]': <YOUR SITE ID>,
            'data[Video][mp4]': 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
            'data[Video][name]': 'NodeJS',
            'data[Video][channel_id]': 13
    }),
    headers: {
        'Authorization': 'Bearer <YOUR AUTH CODE HERE>',
        'User-Agent': 'Api | BridVideo',
        'X-Site': '<YOUR SITE/DOMAIN HERE>'
    }
    })
    .then(function (response) {
        //handle success
        console.log(response);
    })
    .catch(function (response) {
        //handle error
        console.log(response);
    });

Both of the examples above use axios as a node module for making HTTP requests.