@pbvision/partner-sdk 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -20
- package/package.json +1 -1
- package/src/index.js +5 -3
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# PB Vision Partner Documentation <!-- omit in toc -->
|
|
2
2
|
|
|
3
|
+
For policies, pricing, and partner responsibilities refer to our [API Partner Guide](https://help.pb.vision/en/help/articles/2793895-pb-vision-api-partner-guide).
|
|
4
|
+
|
|
3
5
|
The easiest way to use the PB Vision AI Engine is to simply share a link to
|
|
4
6
|
your video file. Our AI usually works on each video for about 30 minutes for a
|
|
5
7
|
standard length game, so we'll notify your servers when the results are ready.
|
|
@@ -12,9 +14,12 @@ standard length game, so we'll notify your servers when the results are ready.
|
|
|
12
14
|
- [Send Videos](#send-videos)
|
|
13
15
|
- [Option 1: PBV downloads your video from a URL](#option-1-pbv-downloads-your-video-from-a-url)
|
|
14
16
|
- [Option 2: Upload your video](#option-2-upload-your-video)
|
|
15
|
-
|
|
17
|
+
- [Video Metadata](#video-metadata)
|
|
18
|
+
- [Video Editors and Viewers](#video-editors-and-viewers)
|
|
16
19
|
- [After Video Processing is Done](#after-video-processing-is-done)
|
|
17
20
|
- [Callback Data](#callback-data)
|
|
21
|
+
- [Fetching Insights by Video ID](#fetching-insights-by-video-id)
|
|
22
|
+
- [Player Identification](#player-identification)
|
|
18
23
|
- [Video Guidelines](#video-guidelines)
|
|
19
24
|
- [Reference Guide](#reference-guide)
|
|
20
25
|
|
|
@@ -80,13 +85,12 @@ Next, tell us to download and work on the video. You can do this using our SDK:
|
|
|
80
85
|
import { PBVision } from '@pbvision/partner-sdk';
|
|
81
86
|
|
|
82
87
|
const pbv = new PBVision(YOUR_API_KEY, { useProdServer: true });
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
userEmails: [], // these users will have the video in their PB Vision library
|
|
88
|
+
const metadata = {
|
|
89
|
+
userEmails: ['player1@example.com', 'player2@example.com'],
|
|
86
90
|
name: 'Dink Championship 2025',
|
|
87
|
-
gameStartEpoch: 1711393200,
|
|
91
|
+
gameStartEpoch: 1711393200,
|
|
88
92
|
};
|
|
89
|
-
await pbv.sendVideoUrlToDownload(YOUR_VIDEO_URL,
|
|
93
|
+
const { vid } = await pbv.sendVideoUrlToDownload(YOUR_VIDEO_URL, metadata);
|
|
90
94
|
```
|
|
91
95
|
|
|
92
96
|
Alternatively, you can just use `curl`:
|
|
@@ -107,24 +111,58 @@ You can directly upload your video from a file using the SDK too:
|
|
|
107
111
|
import { PBVision } from '@pbvision/partner-sdk';
|
|
108
112
|
|
|
109
113
|
const pbv = new PBVision(YOUR_API_KEY, { useProdServer: true });
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
gameStartEpoch: 1711393200, // when the game was played
|
|
114
|
+
const metadata = {
|
|
115
|
+
userEmails: ['player1@example.com'],
|
|
116
|
+
name: 'My Game',
|
|
117
|
+
gameStartEpoch: 1711393200,
|
|
115
118
|
};
|
|
116
|
-
await pbv.uploadVideo(YOUR_VIDEO_FILENAME,
|
|
119
|
+
const { vid } = await pbv.uploadVideo(YOUR_VIDEO_FILENAME, metadata);
|
|
117
120
|
```
|
|
118
121
|
|
|
119
|
-
|
|
122
|
+
#### Video Metadata
|
|
123
|
+
|
|
124
|
+
Both `sendVideoUrlToDownload()` and `uploadVideo()` accept an optional metadata
|
|
125
|
+
object. You can omit it entirely, or provide some or all of these fields:
|
|
126
|
+
|
|
127
|
+
| Field | Type | Description |
|
|
128
|
+
|-------|------|-------------|
|
|
129
|
+
| `userEmails` | `string[]` | Up to 4 email addresses of players in the game. These users will have the video added to their PB Vision library, become editors on the video, and be notified when processing is complete. |
|
|
130
|
+
| `name` | `string` | Title of the game. Defaults to the game time, or the upload time if no game time is provided. |
|
|
131
|
+
| `desc` | `string` | A longer description of the game. |
|
|
132
|
+
| `gameStartEpoch` | `integer` | Unix timestamp (seconds) of when the game was played. |
|
|
133
|
+
| `facility` | `string` | Name of the facility where the game was recorded, e.g. `"Cool Club #3 - Barcelona"`. Useful for facility and Court Insight integrations. |
|
|
134
|
+
| `court` | `string` | Court identifier where the game was recorded, e.g. `"11A"`. Useful for facility and Court Insight integrations. |
|
|
135
|
+
| `fid` | `integer` | Folder ID. Organizes the video into a specific folder in the uploader's PB Vision library. |
|
|
120
136
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
137
|
+
The `facility` and `court` fields are primarily used by facility partners
|
|
138
|
+
running [Court Insight](https://help.pb.vision/en/articles/9341690-court-insight-for-facilities-and-clubs)
|
|
139
|
+
or similar venue-based integrations, where tracking which court a game came from
|
|
140
|
+
is important. League and tournament partners may also find these useful for
|
|
141
|
+
organizing videos by location.
|
|
124
142
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
143
|
+
### Video Editors and Viewers
|
|
144
|
+
|
|
145
|
+
Editors can tag themselves and friends in the video. Viewers have read-only
|
|
146
|
+
access. Both editors and viewers can access the video even if it is private (to
|
|
147
|
+
make videos uploaded by your partner account private by default, please let us
|
|
148
|
+
know via email).
|
|
149
|
+
|
|
150
|
+
You can get the current list of editors on a video using `getVideoEditors()`.
|
|
151
|
+
Use `setVideoEditors()` to set both editor and viewer access (up to 8 emails
|
|
152
|
+
each). Note that `setVideoEditors()` _replaces_ the existing editors and
|
|
153
|
+
viewers lists entirely.
|
|
154
|
+
|
|
155
|
+
```javascript
|
|
156
|
+
// Get current editors
|
|
157
|
+
const editors = await pbv.getVideoEditors(vid);
|
|
158
|
+
|
|
159
|
+
// Set editors and viewers (replaces any previous lists)
|
|
160
|
+
await pbv.setVideoEditors(
|
|
161
|
+
vid,
|
|
162
|
+
['editor1@example.com', 'editor2@example.com'], // editors
|
|
163
|
+
['viewer1@example.com'] // viewers
|
|
164
|
+
);
|
|
165
|
+
```
|
|
128
166
|
|
|
129
167
|
## After Video Processing is Done
|
|
130
168
|
|
|
@@ -170,10 +208,74 @@ data is enabled for your API key, only some of these fields may be present):
|
|
|
170
208
|
- only included if `insights` is included:
|
|
171
209
|
- `vid` - the unique ID of the video in our system
|
|
172
210
|
- `aiEngineVersion` - the version number of our AI used to process the video
|
|
173
|
-
|
|
211
|
+
|
|
212
|
+
### Fetching Insights by Video ID
|
|
213
|
+
|
|
214
|
+
If you need to retrieve the insights data outside of the webhook callback (for
|
|
215
|
+
example, to re-fetch data for a previously processed video), you can use a
|
|
216
|
+
simple HTTP GET request with the video ID:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
curl https://api-2o2klzx4pa-uc.a.run.app/video/VIDEO_ID/insights.json
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
This returns the same insights JSON that would be delivered via the webhook
|
|
223
|
+
callback. You can call this endpoint as many times as needed.
|
|
224
|
+
|
|
225
|
+
### Player Identification
|
|
226
|
+
|
|
227
|
+
PB Vision assigns each detected player an index based on visual detection.
|
|
228
|
+
Players are indexed 0-3 for doubles (0-1 on one team, 2-3 on the other) and
|
|
229
|
+
0 and 2 for singles. These indices are consistent _within_ a single video but
|
|
230
|
+
do not carry over between videos, so "Player 0" in one video is not necessarily
|
|
231
|
+
the same person as "Player 0" in another.
|
|
232
|
+
|
|
233
|
+
**Player thumbnails** are available after processing. Using the `vid` and
|
|
234
|
+
`aiEngineVersion` from the webhook callback, you can fetch thumbnail images for
|
|
235
|
+
each player:
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
https://storage.googleapis.com/pbv-pro/{vid}/{aiEngineVersion}/player{playerIndex}-{imageIndex}.jpg
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
- `playerIndex`: 0-3 for doubles, 0 and 2 for singles
|
|
242
|
+
- `imageIndex`: 0-7 (up to 8 thumbnails per player, captured at different
|
|
243
|
+
points in the game)
|
|
244
|
+
|
|
245
|
+
For example, to get thumbnails for all four players in a doubles game:
|
|
246
|
+
|
|
247
|
+
```
|
|
248
|
+
https://storage.googleapis.com/pbv-pro/83gyqyc10y8f/7/player0-0.jpg
|
|
249
|
+
https://storage.googleapis.com/pbv-pro/83gyqyc10y8f/7/player1-0.jpg
|
|
250
|
+
https://storage.googleapis.com/pbv-pro/83gyqyc10y8f/7/player2-0.jpg
|
|
251
|
+
https://storage.googleapis.com/pbv-pro/83gyqyc10y8f/7/player3-0.jpg
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Mapping players to your system:** If your integration needs to know which
|
|
255
|
+
player is which (e.g. linking game stats to player profiles in your app), you
|
|
256
|
+
have a few options:
|
|
257
|
+
|
|
258
|
+
1. **Pass player emails at upload time** via the `userEmails` metadata field.
|
|
259
|
+
If you know which players are in the match, their emails will be associated
|
|
260
|
+
with the video as editors, and you can match them against your records.
|
|
261
|
+
|
|
262
|
+
2. **Use thumbnails for manual or automated matching.** After processing, fetch
|
|
263
|
+
the player thumbnails and either surface them in an admin UI for manual
|
|
264
|
+
confirmation, or compare them against known player photos programmatically.
|
|
265
|
+
|
|
266
|
+
3. **Store your own metadata alongside the video ID.** When you upload a video,
|
|
267
|
+
record the returned `vid` alongside whatever context you have (match ID,
|
|
268
|
+
player roster, season, week, etc.) in your own system. When the webhook
|
|
269
|
+
fires, use the `vid` to look up that context and route the results
|
|
270
|
+
accordingly.
|
|
271
|
+
|
|
272
|
+
The insights JSON also includes an `avatar_id` for each player, which
|
|
273
|
+
corresponds to the `playerIndex` used in the thumbnail URLs above.
|
|
174
274
|
|
|
175
275
|
## Video Guidelines
|
|
176
276
|
|
|
277
|
+
Note: We are now able to split videos into individual games if you'd like to upload more than one game per video. Let us know if this applies to your use case.
|
|
278
|
+
|
|
177
279
|
Requirements:
|
|
178
280
|
|
|
179
281
|
- Comply with [PB Vision's framing guidelines](https://help.pb.vision/en/help/articles/1108176-video-recording-and-framing-tips)
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -62,11 +62,13 @@ export class PBVision {
|
|
|
62
62
|
* partner account uploaded.
|
|
63
63
|
*
|
|
64
64
|
* @param {string} vid video id
|
|
65
|
-
* @param {Array<string>} editorEmails a list of 0 to
|
|
65
|
+
* @param {Array<string>} editorEmails a list of 0 to 8 email addresses to
|
|
66
66
|
* allow edit access to the video (replaces any previous editors list).
|
|
67
|
+
* @param {Array<string>} viewerEmails a list of 0 to 8 email addresses to
|
|
68
|
+
* allow view access to the video (replaces any previous editors list).
|
|
67
69
|
*/
|
|
68
|
-
async setVideoEditors (vid, editorEmails) {
|
|
69
|
-
return this.__callAPI('video/editors/set', { vid, editorEmails })
|
|
70
|
+
async setVideoEditors (vid, editorEmails, viewerEmails) {
|
|
71
|
+
return this.__callAPI('video/editors/set', { vid, editorEmails, viewerEmails })
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
/**
|