Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Documentation for Javascript and web-components, configuration steps, and more.
The latest version of the SDK is published on https://github.com/snapodds/sdk-js/releases and contains a web-component for rendering the Snapscreen UI and the necessary initialization API.
The JavaScript source code, for reference, is available at https://github.com/snapodds/sdk-js. To stay informed about the latest updates and improvements, we recommend to watch this repository https://github.com/snapodds/sdk-js/releases on GitHub .
The SDK can be integrated in:
Browsers that support Custom Elements
Browsers that support CSS Variables
Browsers that support Promises
A sample integration of the SDK can be found at https://github.com/snapodds/sdk-js-sample.
When integrating the SDK please make sure to follow our Integration Guide for a great customer experience.
Requirement:
A license key is required to use our API. You can obtain a license by contacting us at: hello@snapodds.com
The following license keys can be used for trial purposes only:
Client ID: u9jYT9g1q6gTxY8i
Client Secret: RMkiJPYCipP5bbG4YbtqzpdYne1b0hPSDItvq3YV
With this configuration, the web-component is able to "snap" an image of supported live TV sports stream and retrieve information on the currently playing sporting event.
The customer's web application will then render not only the details of the sporting event, but the odds information for the matched game.
This is the simplest implementation, as all of the heavy lifting is done by the SnapOdds SDK.
With this configuration, the web component is able to "snap" an image of a live TV stream and retrieve information on the currently playing sporting event shown.
It is expected that the customer's web application will use the response from the SDK to render more detailed information about the sporting event.
The Betradar ID
is provided in each SDK response, in order to match the response from the SDK with your data.
Covers the handling of tokens for authentication purposes.
The SnapOdds SDK requires a valid access token to be provided in order to communicate with the Snapscreen API, which uses the OAuth 2.0 authentication mechanism.
Our customers are provided with a Client ID
and Secret
which must be used to retrieve the access token from the API endpoint described below:
POST
https://api.us.snapscreen.com/oauth/token
Name | Type | Description |
---|---|---|
Below is an example of the HTTP request using curl
to receive an access token:
Having the access token retrieval system implemented on the client side is unsafe and strongly discouraged, as credentials are available in plain text and could easily be stolen. Therefore SnapOdds recommends implementation of this logic on the server side.
For the implementation to function, a REST API endpoint must be provided from which the client can request the access token. On the server side, the access token will be fetched from the Snapscreen API, stored in the current HTTP session, and then returned to the browser.
To further improve security, we also recommend using the CSRF token technique to protect this resource. If you have other security protection mechanisms available in your Web Application, then we highly recommend using them as well.
Let us assume a REST API endpoint has been created using the path '/token'
. The next required step is to direct this endpoint to the SnapOdds SDK in the form of an access token provider, which is function
that when executed will return a Promise
of the whole access token returned from the Snapscreen API.
Enclosed below is a snippet of a basic implementation of the access token provider.
Note: The access token provider must return a standard Promise (not any equivalent like AngularJS $q or other custom promise libraries like Kris Kowal's Q). The SDK is built as angular element and relies on zone.js for change detection, so only browser native async methods are recognized.
Covers the handling of tokens for authentication purposes.
The SnapOdds SDK requires a valid access token to be provided in order to communicate with the Snapscreen API, which uses the OAuth 2.0 authentication mechanism.
Our customers are provided with a Client ID
and Secret
which must be used to retrieve the access token from the API endpoint described below:
POST
https://api.us.snapscreen.com/oauth/token
Name | Type | Description |
---|
Below is an example of the HTTP request using curl
to receive an access token:
Having the access token retrieval system implemented on the client side is unsafe and strongly discouraged, as credentials are available in plain text and could easily be stolen. Therefore SnapOdds recommends implementation of this logic on the server side.
For the implementation to function, a REST API endpoint must be provided from which the client can request the access token. On the server side, the access token will be fetched from the Snapscreen API, stored in the current HTTP session, and then returned to the browser.
Enclosed below is a snippet of a basic implementation of the access token provider.
If you want to customize the colors of the UI you can simply override the CSS Variables in snapodds-sdk.css
.
Obtaining live sporting event information by 'snapping'
The following section deals primarily with the code used in capture of live game information for SnapOdds Operator. If your use case requires game odds to be presented, the information captured by SnapOdds Operator is fed into SnapOdds Sports Media to correlate the game odds information, as described in .
With this configuration, the web component is able to "snap" an image of a live TV stream and retrieve information on the currently playing sporting event shown. It is expected that the customer's web application will use the response from the SDK to render more detailed information about the sporting event.
First, ensure both the JavaScript and CSS resource are correctly loaded and that the access token manager is correctly implemented.
To render the SnapOdds SDK component, a DOM element must be provided, to which the component will be attached to as a child. In most cases, the document.body
component works best, as the SDK is then added as the last child, which helps with styling as the SDK overlays the full viewport.
Next, it is necessary to configure the SDK and add it as a child to the DOM element of your choice. This can be done by using SnapoddsSdk.snapBuilder()
.
The following configuration is the simplest one and will show the SDK immediately after appendTo()
is called.
The SDK can provide you with the information if there is at least one sportsEvent live, based on your channel's configuration.
Instead of appending the SDK to the document.body
, you need to configure the onLiveEventsStatusChangedCallback()
first. Therefore, you have to call build()
instead of appendTo()
at the end of the SDK's initialisation in order for it to work.
The callback you provide will be executed after initialisation and will return either true
or false,
indicating that there is at least one live sportsEvent available or not.
After that, it will automatically check every 5 minutes for upcoming sportEvents. If one is found the callback will be invoked as soon as the sportsEvent starts..
The following parameters are used in the SnapoddsSdk.operatorsBuilder()
:
tvSearchResult
has the following format:
Obtaining sporting event odds and presenting them to the application.
If game odds are required, SnapOdds Sports Media is called upon to obtain odds information. The info obtained by SnapOdds Operator (as described in ) is used to correlate the game odds information with the captured live game.
First, ensure both the JavaScript and CSS resource are correctly loaded and that the access token manager is correctly implemented.
To render the SnapOdds SDK component, a DOM element must be provided, to which the component will be attached as a child. In most cases, the document.body
component works best, as the SDK is then added as the last child, which helps with styling as the SDK overlays the full viewport.
Next, it is necessary to configure the SDK and add it as a child to the DOM element of your choice. This can be done by using SnapoddsSdk.snapBuilder()
.
The following configuration is the simplest one and will show the SDK immediately after appendTo()
is called.
The SDK can provide you with the information if there is at least one sportsEvent live, based on your channel's configuration.
Instead of appending the SDK to the document.body
, you need to configure the onLiveEventsStatusChangedCallback()
first. Therefore, you have to call build()
instead of appendTo()
at the end of the SDK's initialisation in order for it to work.
The callback you provide will be executed after initialisation and will return either true
or false,
indicating that there is at least one live sportsEvent available or not.
After that, it will automatically check every 5 minutes for upcoming sportEvents. If one is found the callback will be invoked as soon as the sportsEvent starts..
As sports books can have different landing pages per US state, SnapOdds offers the possibility to automatically filter the presented Odds based on the customers IP address.
Furthermore, the US state can also manually be set, when configuring the SDK. When set it will overrule the automatically detected geolocation.
The following parameters are used in the SnapoddsSdk.sportsMediaBuilder()
:
Installing the JavaScript SDK.
To set up the JavaScript SDK two files must be made available:
JavaScript resource
CSS resource
Both files must be added to your web application's index.html. These files are made available via CDN (Content Delivery Network). The following code can be copied and pasted to access the CDN and obtain the SDK.
The SDK must be presented on the whole viewport. For this reason, the following styles must be added. If you already have overlaying elements rendered inside your page, please adjust your z-index
accordingly.
Installing the JavaScript SDK.
To set up the JavaScript SDK two files must be made available:
JavaScript resource
CSS resource
Both files must be added to your web application's index.html. These files are made available via CDN (Content Delivery Network). The following code can be copied and pasted to access the CDN and obtain the SDK.
The SDK must be presented on the whole viewport. For this reason, the following styles must be added. If you already have overlaying elements rendered inside your page, please adjust your z-index
accordingly.
If you want to customize the colors of the UI you can simply override the CSS Variables in snapodds-sdk.css
.
To further improve security, we also recommend using the technique to protect this resource. If you have other security protection mechanisms available in your Web Application, then we highly recommend using them as well.
Let us assume a REST API endpoint has been created using the path '/token'
. The next required step is to direct this endpoint to the SnapOdds SDK in the form of an access token provider, which is function
that when executed will return a of the whole access token returned from the Snapscreen API.
Note: The access token provider must return a standard (not any equivalent like or other custom promise libraries like ). The SDK is built as angular element and relies on for change detection, so only browser native async methods are recognized.
Method | Parameter | Default Value | Description |
---|
This feature can be enabled via the customer level settings. If you wish to enable it, please contact .
For further instructions, please lookup the setUsState
method in the sections.
Method | Parameter | Default Value | Description |
---|
client_id*
String
The client identifier specific to the customer.
client_secret*
String
The client secret.
grant_type*
String
The requested access grant type, should be set to "anonymous".
device_fingerprint
String
Unique device fingerprint.
client_id* | String | The client identifier specific to the customer. |
client_secret* | String | The client secret. |
grant_type* | String | The requested access grant type, should be set to "anonymous". |
device_fingerprint | String | Unique device fingerprint. |
If the implementation of the accessTokenProvider
method is missing this JavaScript error is thrown and shows up in the browsers developer console. No visual feedback is provided to the user as this is a typical implementation mistake. Please check the reference implementation available at #fetch-accesstoken-example.
In this case, please make sure that the the response
from the accessTokenProvider
returns a valid accessToken
JSON object that contains the following properties:
As the accessToken is retrieved after the SnapOdds WebComponent has been rendered, the user will be shown an Integration Error screen and the error shows up in the browsers developer console.
If the promise returned by the accessTokenProvider
method is rejected or can't be performed due to network problems then this error is thrown.
Make sure that your endpoint which provides the accessToken is reachable and check for any network errors in your browsers network tab.
As the accessToken is retrieved after the SnapOdds WebComponent has been rendered, the user will be shown an Integration Error screen and the error shows up in the browsers developer console.
setLanguage | string | en | Set the language of the SDK. |
setAutoSnap | boolean | false | Turns on the auto snap functionality. |
setVibrate | boolean | false | Uses the phones vibrate functionality, when the snap was successful. |
setAccessTokenProvider | function | function that throws an error if not set |
onLiveEventsStatusChangedCallback | function( | no operation | Callback function executed after initialisation and when an upcoming sportsEvent becomes live |
onResults | no operation | Callback function executed when sports events are detected. |
onClose | function(): void | no operation | Callback function to handle SDK close events. |
appendTo | DOM Element | none | This call will finish the web component configuration and appends it to the given DOM element as child node. |
build | none | none | Returns an intermeediate instance of the SdkBuilder. Needs to be used in combination with |
setSnapBackHidden | boolean | false | Hide the "back" button in the Snap view |
setLanguage | string | en | Set the language of the SDK. |
setAutoSnap | boolean | false | Turns on the auto snap functionality. |
setVibrate | boolean | false | Uses the phones vibrate functionality, when the snap was successful. |
setUsState | string | none | A two digit ISO code to identify an US State. Will be used to filter the Odds. |
setAccessTokenProvider | function | function that throws an error if not set |
onLiveEventsStatusChangedCallback | function( | none | Callback function executed after initialisation and when an upcoming sportsEvent becomes live |
onClose | function(): void | no operation | Callback function to handle SDK close events. |
appendTo | DOM Element | none | This call will finish the web component configuration and appends it to the given DOM element as child node. |
build | none | none | Returns an intermeediate instance of the SdkBuilder. Needs to be used in combination with |
A function that takes no parameters and returns the Promise of the access token See for more information.
function(): void
A function that takes no parameters and returns the Promise of the access token See for more information.