ran.de provides for some sport events a live stream in Germany. This article shows you the API behind it (tested only with the NFL streams). Since it is undocumented it can change anytime.

What livestreams are planned?

First we need to know, if a stream is currently online. For this, the following URL gives us a lot of details about this:

https://middleware.7tv.de/ran-mega/mobile/v1/livestreams.json

The response json contains information about what streams are planned and when it starts. Each “content” element is a livestream. The important tag is here the “resource”.

This resource element contains the first fields used for the token generation.

The important information that we need from this file is the “url” and the “stream_url”. Both are used in the next step.

Client Token 1

Now we need to calculate a client token. This token is used for the next API call.

Step 1: Building a string with all relevant information: stream-url + salt + “ran” + url

The current salt is “01!8d8F_)r9]4s[qeuXfP%” (might change in the future).

In our example: “ran-ri-event0301!8d8F_)r9]4s[qeuXfP%ranhttp://www.ran.de/us-sport/nfl/live/rannfl-der-15-spieltag-der-nfl-saison-2018-live-new-england-patriots-at-pittsburgh-steelers-auf-prosieben-maxx-und-auf-ran-de

Step 2: Now build a SHA1 hash of this:

Example: 8f1912cc8c26792652934c3315d040dd758f463d

Step 3: Last step is to prepend a “01”.

Example: 018f1912cc8c26792652934c3315d040dd758f463d

This value is used as “client_token” in the next API call.

Server Token

Now we need to request a server token and the available streaming protocols. This is done by using the following URL:

https://vas-live.p7s1video.net/live/1.0/getprotocols?access_token=ran&client_location={{url}}&property_name={{stream_url}}&client_token={{token}}&secure_delivery=true

The following variables are used:

url: This is the “url” returned in the resources.json file.

stream_url: This is the “stream_url” field of the resources.json file.

token: This is the client token calculated in the chapter above.

From the response we need here the “server_token” field. This will be used from now for token creation.

You must choose now also one of the streaming protocols:

  • HLS (HTTP Live Streaming): This protocol is commonly used for Apple devices (Safari on iOS and MacOS).
  • Dash (Dynamic Adaptive Streaming over HTTP): This protocol is commonly used for Google devices (e.g. Chrome on nearly every platform).
  • HDS (HTTP Dynamic Streaming): This protocol is commonly used in FlashPlayers.

We use HLS in the following steps as an example.

Client Token 2

From now on the the token creation changes.

Step 1: Building a string with all relevant information: stream-url + salt + “ran” + server-token + url + stream-protocol

In our example here: “ran-ri-event0301!8d8F_)r9]4s[qeuXfP%ranJAtV5x1NkeBgGJ0j9FnEyRwDW_rjSrLRT33U_RXwD78cYzoFpEHtfd9e4WkC6g7JaKQL32Vu-9I8OQy_t7l5Yyez1jn-NuZIKWv7eAUN9GquK6LypD10JU4sSTUfFGwMFvt5rbpknp1pzJvcBaGCNghttp://www.ran.de/us-sport/nfl/live/rannfl-der-15-spieltag-der-nfl-saison-2018-live-new-england-patriots-at-pittsburgh-steelers-auf-prosieben-maxx-und-auf-ran-dehls

Step 2: Now build a SHA1 hash of this:

Example: 0b2d6b8f57ecd98adeb54990b5ca4ab1ef7d0f15

Step 3: Last step is to prepend a “01”.

Example: 010b2d6b8f57ecd98adeb54990b5ca4ab1ef7d0f15

From now on this is our new client token.

Receiving the Streaming URL

Now it’s time to receive the streaming URL for the event:

https://vas-live.p7s1video.net/live/1.0/geturls?access_token=ran&client_location={{url}}&property_name={{stream_url}}&protocols={{protocol}}&server_token={{server_token}}&client_token={{token}}&secure_delivery=true

The parameters “url” and “stream_url” has not changed since the last call and the other variables must be filled with:

token: This is the new client token calculated in the chapter above.

protocol: This value must match with the protocol chosen for the token generation.

Returned is now a URL with the livestream. Just copy the URL into some video player or browser (e.g. HLS is directly played in Safari).

Enjoy.