1.0.69 • Published 4 years ago

hotstreak v1.0.69

Weekly downloads
24
License
MIT
Repository
github
Last release
4 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

4 years ago

1.0.66

4 years ago

1.0.65

4 years ago

1.0.68

4 years ago

1.0.67

4 years ago

1.0.64

4 years ago

1.0.63

4 years ago

1.0.62

4 years ago

1.0.61

4 years ago

1.0.60

4 years ago

1.0.59

4 years ago

1.0.49

4 years ago

1.0.51

4 years ago

1.0.50

4 years ago

1.0.55

4 years ago

1.0.54

4 years ago

1.0.53

4 years ago

1.0.52

4 years ago

1.0.58

4 years ago

1.0.57

4 years ago

1.0.56

4 years ago

1.0.48

4 years ago

1.0.44

4 years ago

1.0.47

4 years ago

1.0.46

4 years ago

1.0.45

4 years ago

1.0.39

4 years ago

1.0.40

4 years ago

1.0.43

4 years ago

1.0.42

4 years ago

1.0.41

4 years ago

1.0.38

4 years ago

1.0.37

4 years ago

1.0.36

4 years ago

1.0.35

4 years ago

1.0.33

4 years ago

1.0.34

4 years ago

1.0.32

4 years ago

1.0.31

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.30

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago