Skip to main content

IP and GeoRules

IP Geo rules is passed as a string. The string contains an array of JSON objects. Each JSON object is a rule-set, in which you include and exclude IP addresses. Please refer to the blog on creating an appropriate ruleset.

A sample rule-set for the case wherein you would like to block access everywhere with the exception of India and Britain is:

{  "ipGeoRules":"[  {    "action": "false",    "ipSet": [],    "countrySet": []  },  {    "action": "true",    "ipSet": [],    "countrySet": ["IN", "GB"]  }]"}

Get OTP Sample Code#

The sample videoID is 1234567890 and the API Secret Key is a1b2c3d4e5. This sample code passes IP Geo Rules as parameter, blocking video access at all locations, and then whitelists video playback in India (IN) and Britain (GB). Please scroll below for more examples.

curl -X POST \  https://dev.vdocipher.com/api/videos/1234567890/otp \  -H 'Accept: application/json' \  -H 'Authorization: Apisecret a1b2c3d4e5' \  -H 'Content-Type: application/json' \  -d '{  "ipGeoRules":"[{'\''action'\'': '\''false'\'','\''ipSet'\'': [],'\''countrySet'\'': []},{'\''action'\'': '\''true'\'','\''ipSet'\'': [],'\''countrySet'\'': ['\''IN'\'', '\''GB'\'']}]"}'

Examples#

By default the video is accessible across all IP addresses and all geo-locations. If you want to limit access to only a few locations, the first rule-set should block all IPs and Geo-locations. We will then selectively allow where video playback is to be allowed.

The ruleset below blocks video playback at ALL IP addresses and ALL Geolocations.

"ipGeoRules":"[  {    "action": "false",    "ipSet": [],    "countrySet": []  }  ]"

To allow video access to certain IPs/Geolocations, add a second rule set:

  {    "action": "true",    "ipSet": [],    "countrySet": ["IN", "GB"]  }

This would allow videos to be played at ALL IP addresses in India and Britain.

Because by default videos are available everywhere, to blacklist certain locations, you would only need to add one rule-set to selectively block video playback at those IPs / Geo-locations. The following ruleset blocks video playback in India and Britain.

{  "ipGeoRules":"[  {    "action": "false",    "ipSet": [],    "countrySet": ["IN", "GB"]  }]"}

The later ruleset always over-rides an earlier rule-set. In the first set of rules given below, IP addresses "122.0.0.0/16" and "49.323.23.56" are disallowed, while in the second rule-set videos are whitelisted in India and GB. The net effect is that IP addresses "122.0.0.0/16" and "49.323.23.56", if not originating in India or GB are disallowed. This because the later rule over-rides the former rule in case of conflict.

{  "ipGeoRules":"[  {    "action": "false",    "ipSet": ["122.0.0.0/16", "49.323.23.56"],    "countrySet": []  },  {    "action": "true",    "ipSet": [],    "countrySet": ["IN", "GB"]  }]"}