1.0.69 • Published 3 years ago

hotstreak v1.0.69

Weekly downloads
24
License
MIT
Repository
github
Last release
3 years ago

HotStreak JavaScript SDK

The HotStreak JavaScript SDK provides convenient access to HotStreak's real-time market feeds.

Installation

Install the package with:

yarn add hotstreak
# or
npm i hotstreak --save

Usage

To import the package:

import HotStreak from 'hotstreak';
// or
const HotStreak = require('hotstreak');

HotStreak needs to be initialized with:

  1. The URL of the environment you want to point to as baseUrl
  2. Credentials

    • Server (i.e. node) - pass key and secret directly
    • Client (i.e. browser, mobile device, etc.) - generate a JWT signed with secret on server. Then pass the JWT to your client. The JWT payload must contain your API key, and may contain a subject identifiying your client
    { iss: key, subject: 'optional_client_id', exp: TIMESTAMP_IN_FUTURE }

🚨 You should NOT deploy your API secret to the client directly!

// server initialization
const hotstreak = new HotStreak({
  baseUrl: 'BASE_URL',
  key: 'YOUR_KEY',
  secret: 'YOUR_SECRET'
});

// client initialization
const jwt = await getJwtFromYourServer();
const hotstreak = new HotStreak({
  baseUrl: 'BASE_URL',
  token: jwt
});

Subscribing to a game:

const leagues = await hotstreak.fetchLeagues();
// TODO: push leagues to your store

hotstreak.subscribe(leagues[0], (game, markets) => {
  // TODO: push game & markets to your store
  console.log(game);
  console.log(markets);
});

Unsubscribing from a game:

hotstreak.unsubscribeFromChannel(game.broadcastChannel);

Making a Prediction:

const prediction = hotstreak.predict(game, market, 'over');

Prediction Web Hook:

Results are communicated via a POST web hook registered with your API KEY. Example web hook payload

{
  "prediction_id": "Prediction:P87Fbd",
  "sequence": 4,
  "timestamp": 1598983584.4778883,
  "state": "finalized",
  "actual_outcome": "over",
  "predicted_outcome": "over",
  "category": "rebounds",
  "current": 1.0,
  "subject": null,
  "meta": null,
  "id": "0c9a89371d6f96bd2c674b1bd58c58e311526a3f"
}
1.0.69

3 years ago

1.0.66

3 years ago

1.0.65

3 years ago

1.0.68

3 years ago

1.0.67

3 years ago

1.0.64

3 years ago

1.0.63

3 years ago

1.0.62

3 years ago

1.0.61

3 years ago

1.0.60

3 years ago

1.0.59

3 years ago

1.0.49

3 years ago

1.0.51

3 years ago

1.0.50

3 years ago

1.0.55

3 years ago

1.0.54

3 years ago

1.0.53

3 years ago

1.0.52

3 years ago

1.0.58

3 years ago

1.0.57

3 years ago

1.0.56

3 years ago

1.0.48

3 years ago

1.0.44

3 years ago

1.0.47

3 years ago

1.0.46

3 years ago

1.0.45

3 years ago

1.0.39

3 years ago

1.0.40

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.41

3 years ago

1.0.38

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.33

3 years ago

1.0.34

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.30

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago