Sporfie API (1.5.3)

Download OpenAPI specification:Download

Introduction

The Sporfie system exposes a set of REST APIs at https://api.sporfie.com.

These APIs allow you to

  • list Places
  • lookup Events
  • get detailed Event information
  • create/edit/delete Events
  • register/unregister for notification on Event changes
  • trigger the generation of highlight videos on an Event

Authentication

This API will only answer to authenticated requests.

A request is authenticated by adding the token we have given you in the HTTP request header:

Authorization: Bearer {token}

Place data

Retrieval of Place data

Places

This end point returns all the Places of the targeted Company/organization

query Parameters
companyKey
required
string

The company/organization's key

Responses

Response samples

Content type
application/json
{
  • "places": [
    ]
}

Event data

Retrieval of Event data

Event lookup by place and time

Finds a specific Sporfie Event for a given place and time.

The end point looks for the event that started after, and within one hour of, the given date and time and returns its unique identifier. If there are several matching events (multiple events on that place within the same hour), the key of the first one is returned.

Important: the date & time information must be given in UTC, not local time.

query Parameters
placeKey
required
string
Example: placeKey=Place_345

The Place identifier

year
required
number
Example: year=2021

The year the event started (UTC)

month
required
integer [ 1 .. 12 ]
Example: month=5

The month the event started (UTC)

day
required
integer [ 1 .. 31 ]
Example: day=6

The day the event started (UTC)

hour
required
integer [ 0 .. 23 ]
Example: hour=16

The hour the event started (UTC)

Responses

Response samples

Content type
application/json
{
  • "eventKey": "string"
}

Active Event on Place

Returns the key of the event currently active on the given place.

If no event is currently active on that place a 404 is returned instead.

path Parameters
placeKey
required
string

Responses

Response samples

Content type
application/json
{
  • "activeEventKey": "string"
}

Event data

This end point returns all the relevant data for the given event key.

Note event data changes over time as the event unfolds, e.g. live streams are started and stopped, moments are captured, etc.

This API returns a snapshot of the event data at the time of the request. To stay informed of changes in the event data, use the Watch API.

eventKey may either be a Sporfie-internal event key, or an event's externalID.

path Parameters
eventKey
required
string

The event externalID or eventKey

Responses

Response samples

Content type
application/json
{
  • "key": "string",
  • "externalEventID": "string",
  • "companyKey": "string",
  • "name": "string",
  • "description": "string",
  • "notSearchable": true,
  • "creationDate": 0,
  • "placeKey": "string",
  • "scheduledStartTime": 0,
  • "scheduledEndTime": 0,
  • "announcedTime": 0,
  • "startTime": 0,
  • "endTime": 0,
  • "thumbnailURL": "string",
  • "homeTeam": "string",
  • "awayTeam": "string",
  • "shortInviteUrl": "string",
  • "sport": "string",
  • "pinCode": 0,
  • "cameraPinCode": 0,
  • "scoreSupported": true,
  • "score": {
    },
  • "scoreStream": [
    ],
  • "highlightsURL": "string",
  • "highlightsShareURL": "string",
  • "location": {
    },
  • "moments": [
    ],
  • "mediaFiles": [
    ],
  • "hiddenDevices": { },
  • "liveStreams": [
    ],
  • "metadata": { }
}

Delete event

Deletes an event.

eventKey may either be a Sporfie-internal event key, or an event's externalID.

An event may only be deleted if it is not currently running (has started and has not yet ended).

path Parameters
eventKey
required
string

The event externalID or eventKey

Responses

Create event

Creates an event in the Sporfie database.

The event's externalID is set to the value of the eventKey parameter. Upon successful event creation, the event's internal ID is returned in the response in the eventKey field. The event may thereafter be referred to either by its externalID or its internal eventKey.

You are free to choose your external ID as you see fit, within the following constraints:

  • ASCII characters in the character set [-_0-9a-zA-Z]
  • maximum length of 64 bytes
  • unique and not already used in the context of your access to this system

Only the name and location fields are mandatory in the body data, if placeKey is not set. If placeKey is set, location field is optional because the location will be inherited from the place. name may not be emtpy.

The sport field must be one of the following code:

  • baseball: Baseball
  • basketball: Basketball
  • beachvolleyball: Beach Volleyball
  • bowling: Bowling
  • football: Football
  • frontenis: Frontenis
  • futsal: Futsal
  • golf: Golf
  • hockey: Hockey
  • lacrosse: Lacrosse
  • other: Other
  • soccer: Soccer
  • tennis: Tennis
  • unihockey: Floorball
  • volleyball: Volleyball

If the given sport is not one of those, or if not provided, other will be used.

If placeKey is present, then so must scheduledStartTime and scheduledEndTime.

When provided, scheduledStartTime and scheduledEndTime must both be present and be in the future and scheduledEndTime must be greater than scheduledStartTime by at least 5 minutes.

The thumbnailURL must point to a publicly accessible image resource. The image is copied by the Sporfie system and may be resized or cropped to fit Sporfie's requirements.

path Parameters
eventKey
required
string

The event externalID or eventKey

Request Body schema: application/json
companyKey
required
string

The identifier of the company/organization this event is associated with

name
required
string

The event name. May not be empty.

description
string

The event description

notSearchable
boolean

Set to true to exclude this event from public listing in the Sporfie system. Default value is false.

placeKey
string

The key of the Place on which the event is scheduled to run.

scheduledStartTime
number

The date & time the event is scheduled to start (UTC, epoch in milliseconds)

scheduledEndTime
number

The date & time the event is scheduled to end (UTC, epoch in milliseconds)

thumbnailURL
string

A public URL pointing to the event's thumbnail

homeTeam
string

The name of the team playing at home

awayTeam
string

The name of the team playing away

sport
string

The sport code for this event

pinCode
number

The pin code controlling access to the event. A value of -1 or between 0000 and 9999. A value of -1 indicates no pin code. Default is -1.

cameraPinCode
number

The pin code required to add a camera and edit the score. A value of -1 or between 0000 and 9999. A value of -1 indicates no pin code. Default is -1.

object (Location)

A geo location

metadata
object

A dictionary of custom fields. Its JSON string representation (UTF-8) may not exceed 4000 bytes. Keys may not contain the following characters . $ # [ ] /

hiddenDevices
object

A dictionary of device keys that should be hidden from the event. The keys are the device keys, and the values are true or false.

Responses

Request samples

Content type
application/json
{
  • "companyKey": "string",
  • "name": "string",
  • "description": "string",
  • "notSearchable": true,
  • "placeKey": "string",
  • "scheduledStartTime": 0,
  • "scheduledEndTime": 0,
  • "thumbnailURL": "string",
  • "homeTeam": "string",
  • "awayTeam": "string",
  • "sport": "string",
  • "pinCode": 0,
  • "cameraPinCode": 0,
  • "location": {
    },
  • "metadata": { },
  • "hiddenDevices": { }
}

Response samples

Content type
application/json
{
  • "eventKey": "string"
}

Modify event

Modifies an existing event.

eventKey may either be a Sporfie-internal event key, or an event's externalID.

No field is mandatory in the body data. Only fields present in the body data will be updated in the event, other fields will be left unmodified. The location and metadata fields are considered as atomic values in that respect.

When present, scheduledStartTime and scheduledEndTime must be in the future. Current values of scheduledStartTime and scheduledEndTime must be in the future to be modifiable. The value of placeKey may not be modified if scheduledStartTime is in the past.

The thumbnailURL must point to a publicly accessible image resource. The image is copied by the Sporfie system and may be resized or cropped to fit Sporfie's requirements.

path Parameters
eventKey
required
string

The event externalID or eventKey

Request Body schema: application/json
companyKey
required
string

The identifier of the company/organization this event is associated with

name
required
string

The event name. May not be empty.

description
string

The event description

notSearchable
boolean

Set to true to exclude this event from public listing in the Sporfie system. Default value is false.

placeKey
string

The key of the Place on which the event is scheduled to run.

scheduledStartTime
number

The date & time the event is scheduled to start (UTC, epoch in milliseconds)

scheduledEndTime
number

The date & time the event is scheduled to end (UTC, epoch in milliseconds)

thumbnailURL
string

A public URL pointing to the event's thumbnail

homeTeam
string

The name of the team playing at home

awayTeam
string

The name of the team playing away

sport
string

The sport code for this event

pinCode
number

The pin code controlling access to the event. A value of -1 or between 0000 and 9999. A value of -1 indicates no pin code. Default is -1.

cameraPinCode
number

The pin code required to add a camera and edit the score. A value of -1 or between 0000 and 9999. A value of -1 indicates no pin code. Default is -1.

object (Location)

A geo location

metadata
object

A dictionary of custom fields. Its JSON string representation (UTF-8) may not exceed 4000 bytes. Keys may not contain the following characters . $ # [ ] /

hiddenDevices
object

A dictionary of device keys that should be hidden from the event. The keys are the device keys, and the values are true or false.

Responses

Request samples

Content type
application/json
{
  • "companyKey": "string",
  • "name": "string",
  • "description": "string",
  • "notSearchable": true,
  • "placeKey": "string",
  • "scheduledStartTime": 0,
  • "scheduledEndTime": 0,
  • "thumbnailURL": "string",
  • "homeTeam": "string",
  • "awayTeam": "string",
  • "sport": "string",
  • "pinCode": 0,
  • "cameraPinCode": 0,
  • "location": {
    },
  • "metadata": { },
  • "hiddenDevices": { }
}

Close an event

Immediately closes an event.

When an event is closed, its live streams stop and no new clip generated.

path Parameters
eventKey
required
string

Responses

Add a score entry in the score stream

Add a score entry in the score stream of the event.

eventKey may either be a Sporfie-internal event key, or an event's externalID.

path Parameters
eventKey
required
string

The key of the event to add the score to

Request Body schema: application/json

The score information at timeStamp.

The score object may contain any score information that is relevant for the sport of the event. It must contain a timeStamp field.

The generic score format includes the following fields

  • left: integer, the score of the 'left' player (typically Home)
  • period: integer, the current period (e.g. first half, or second set, etc...)
  • right: integer, the score of the 'right' player (typically Away)

Please ask for details about your sport.

The timeStamp and key fields are reserved field names in the score object.

Sport-specific Score Formats

Tennis

The scoreValue object contains two components: gameScores and pointScore.

  • gameScores is an array of pairs representing sets, where each pair contains games won by home and away teams.
  • pointScore is a pair representing the point total in the current game. Instead of 15, 30, 40, A, the values 1, 2, 3, and 4 are used, respectively. Even though left, right, and period are not used in scoring, they must be present.

Volleyball

The scoreValue object contains only gameScores, which functions similarly to Tennis but without pointScore.

  • Each pair in gameScores represents a set, where values indicate the points won by the home and away teams.
  • The logic for determining a set win differs from Tennis, based on volleyball-specific rules.

Example - Volleyball Score Update

{
  "period": 0,
  "right": -1,
  "left": -1,
  "timeStamp": 1692319468961,
  "scoreValue": {
    "gameScores": [[25, 22], [19, 25], [25, 20]]
  }
}
timeStamp
required
integer

Absolute time of the score information (UTC, unix epoch in milliseconds)

Responses

Request samples

Content type
application/json
{
  • "timeStamp": 0
}

Response samples

Content type
application/json
{
  • "key": "string"
}

Delete a score entry

Delete a score entry from the score stream.

path Parameters
eventKey
required
string

The key of the event to remove the score from

scoreKey
required
string

The key of the score entry

Responses

Event Watch

Observing changes in Events

Watch an event

Register for notification on event changes.

Call this end point when you need to be notified of changes on a specific event.

eventKey may either be a Sporfie-internal event key, or an event's externalID.

Once registered, your webhook will be called whenever anything changes in the event. A change of any of the following event property will trigger a callback

  • event info (name, location, sport, pin codes, teams, start date, end date, organization, public pages, tags)
  • moment addition or state change (e.g. new video)
  • highlights video addition
  • media file (full event recording) addition or update
  • live stream changes

Your webhook is called with the updated event data:

POST {webhook}
{
   ... // Event data, in the same format as returned by the Event data end point
}

This registration call is idempotent, calling it several times will register only one webhook for a given event and any previously registered webhook will be replaced with the new one.

When you don't need to be notified of updates anymore, call the same endpoint with the DELETE verb to unregister.

Important: the registration is valid for a maximum of 12 hours, after which you webhook will be unregistered. To maintain your webhook, you must re-register it within that time limit.

path Parameters
eventKey
required
string

The key of the event to watch

Request Body schema: application/json
url
required
string

The URL our system will call when a change occurs

contentType
required
string

The Content-Type to use in the webhook call. json is the only supported value at this point.

Responses

Request samples

Content type
application/json
{
  • "url": "string",
  • "contentType": "string"
}

Stop watching an event

Call this endpoint to unregister from notifications on a given Event.

event_key may either be a Sporfie-internal event key, or an event's externalID.

path Parameters
eventKey
required
string

The key of the event to watch

Responses

Video generation

Generation of highlight videos

Video Overlay Preview

Use this end point to validate your overlay templates.

You can specify a source video to use using sourceURL or use our default test video by not providing a sourceURL.

The source video is trimmed down to 15 seconds.

Your overlays will be applied to the video and the resulting video's URL is returned in the answer to the call. The video is available for 1 hour at that URL.

The video generation process takes about 30 seconds (up to a minute on the first call) to complete.

Request Body schema: application/json
sourceURL
string

The video on which to test your overlays. This must point to a freely downloadable MP4 video.

required
Array of objects (Overlay)

Responses

Request samples

Content type
application/json
No sample

Response samples

Content type
application/json
{
  • "videoURL": "string"
}

Click

Creates a Click and triggers the recording of a Moment with video clips.

All currently active cameras generate a video clip for the requested time range and upload it to the Sporfie system to create a multi-angle Moment.

eventKey may either be a Sporfie-internal event key, or an event's externalID.

If no startTime and endTime are provided, the default settings for the event's sport are used to compute a recording window.

The score field is an unconstrained dictionary containing the score information for that moment in time. It is stored as is and will appear at that time stamp in the event's score stream.

The players field is optional and lists the players involved in the Moment. When present, this information is used by the Sporfie WebApp to allow the user to filter Moments by player on the Event page.

The metadata field is an optional dictionary that may be used by the caller to store any custom information he/she may want to associate with the Moment. It is stored as is in the Moment generated by the click. See the description of the field for restrictions on the content of this dictionary.

The generated video clips may be augmented with overlays. The list of of overlays to apply is passed in overlays. See the definition of Overlay for details. All clips have the same overlays.

Note retrieving the clips and applyfing the overlays takes a few seconds. Getting a positive response from the server does not indicate that the videos are available, only that the request has been accepted and that the process of generating the videos is under way.

Overlays

An Overlay is a still picture burned into a video clip at a fixed location with a fixed size starting at a given time and for a given duration.

Overlay image

There are two ways to provide the picture to be burned in

  • a URL to a valid PNG or JPG file
  • a URL to an HTML template and a matching list of values for placeholders found in the HTML template
Image url

The imageSource url must point to a freely accessible and valid PNG or JPEG file. When burned into the video, the aspect ratio of the image is maintained.

Template

The templateSource url must point to a freely accessible and valid HTML file.

The HTML may contain any number of placeholders that shall be replaced by values found in the values dictionary.

The template must meet the following requirements:

  • a meta entry specifying the natural rendering size for the scoreboard must be present in the file <meta renderWidth="410" renderHeight="27"/>. The rendered overlay will have the specified size. Note that this is not the final size that the overlay will have in the video, that size is specified by heightPercentOfHeight (see below).
  • all CSS must be included in the HTML file in <style> entries
  • no <script> entry is permitted
  • placeholders in the template shall be framed with square braquets so as to ensure proper replacement without interference with the rest of the HTML. For instance the placeholder text1 shall be used in the HTML as [text1], e.g. <div>[text1]</div>.
  • The keys of the values dictionary are the name of the placeholders, without the braquets, e.g. { "text1": "Training session" }. All placeholders found in the template must have a value in the values dictionary (which can be an empty string if needed).
  • to allow for round corners and visually separated elements, the template is rendered over a transparent background, so <body> must be given a background-color if one does not want a transparent background.
  • external fonts may be referenced in <style> entries as @font-face, e.g.
      @font-face {
        font-family: 'Roboto';
        font-style: normal;
        font-weight: 400;
        src: url(https://fonts.gstatic.com/s/roboto/v27/KFOmCnqEu92Fr1Me5Q.ttf) format('truetype');
      }

The downloaded template and the values are used to generate a PNG image, which is then burned into the video at the given location and time.

Here is a sample template:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta renderWidth="410" renderHeight="27" />
    <style>
      @font-face {
        font-family: 'Roboto';
        font-style: normal;
        font-weight: 400;
        src: url(https://fonts.gstatic.com/s/roboto/v27/KFOmCnqEu92Fr1Me5Q.ttf) format('truetype');
      }
      body {
        width: 100vw;
        height: 100vh;
        margin: 0;
        overflow: hidden;
        font-family: 'Roboto';
      }
      .Score {
        background-color: white;
        color: black;
        font-size: 20px;
        text-align: center;
      }
      .team {
        font-size: 80%;
        display: inline-block;
        padding: 0.1em 0.4em;
        background-color: white;
        color: black;
        vertical-align: middle;
        width: 5em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        text-transform: uppercase;
      }
      .score {
        font-weight: bold;
        display: inline-block;
        padding: 0.1em 0.4em;
        background-color: black;
        color: white;
        vertical-align: middle;
        min-width: 2em;
      }
      .period {
        display: inline-block;
        padding: 0.2em 1em;
        height: 100%;
        font-size: 65%;
        font-weight: bold;
        vertical-align: middle;
        min-width: 2em;
      }
    </style>
  </head>
  <body>
    <div class="Score">
      <div class="team">[home_team]</div>
      <div class="score">[left]</div>
      <div class="period">[period]</div>
      <div class="score">[right]</div>
      <div class="team">[away_team]</div>
    </div>
  </body>
</html>

Placement and sizing

The overlay image is placed in the position specified by position:

position: {
  horizontal: 'left' | 'center' | 'right',
  vertical: 'top' | 'center' | 'bottom'
}

For instance:

{
  ...
  "position": { "horizontal": "left", "vertical": "center" }
  ...
}

will position the overlay on the left side of the video, vertically centered.

The size of the image in the video is defined by the heightPercentOfHeight or widthPercentOfWidth parameter, which specifies the height or width of the image in percent of the height or width of the video. Exactly one of the two parameters must be specified, the other dimension is computed according to the aspect ratio of the image. If both parameters are present, heightPercentOfHeight takes precendence.

When the overlay is placed in a corner or a side, a margin is added vertically and horizontally to detach the overlay from the border of the video. The size of this margin (both horizontally and vertically) is a percentage of the video's width (marginPercentOfWidth) or height (marginPercentOfHeight), either one parameter may be specified, but not both. If both are present, marginPercentOfHeight takes precedence.

Placement in time

Unless specified otherwise, the overlay is shown from the start to the end of the video.

The startTime and duration parameters allow to time the display of the overlay more precisely.

path Parameters
eventKey
required
string

The event key

Request Body schema: application/json
timeStamp
required
integer

Absolute time of the click (UTC, unix epoch in milliseconds)

startTime
integer

Absolute start time of the recording window (UTC, unix epoch in milliseconds). If startTime is present, endTime must also be.

endTime
integer

Absolute end time of the recording window (UTC, unix epoch in milliseconds). If endTime is present, startTime must also be.

object

The score information associated with this moment in time. Must contain the timeStamp field but be may otherwise contain any other sport-specific score information. The timeStamp and key fields are reserved field names in the score object. Keys may not contain the following characters . $ # [ ] /

Array of objects (Overlay)

Overlays to apply on this moment's videos

Array of objects (Player)

Player information

metadata
object

A dictionary of custom fields. Its JSON string representation (UTF-8) may not exceed 500 bytes. Keys may not contain the following characters . $ # [ ] /

Responses

Request samples

Content type
application/json
{
  • "timeStamp": 0,
  • "startTime": 0,
  • "endTime": 0,
  • "score": {
    },
  • "overlays": [
    ],
  • "players": [
    ],
  • "metadata": { }
}

Response samples

Content type
application/json
{
  • "momentKey": "string"
}

Moment data

Moment

This end point returns the data for a given Moment.

path Parameters
momentKey
required
string

The moment key

Responses

Response samples

Content type
application/json
{
  • "key": "string",
  • "eventKey": "string",
  • "momentStatus": "string",
  • "momentStartTime": 0,
  • "score": {
    },
  • "videoClips": [
    ],
  • "players": [
    ],
  • "metadata": { }
}

Update moment data

Modifies some properties of a moment.

No field is mandatory in the body data. Only fields present in the body data will be updated in the moment, other fields will be left unmodified.

path Parameters
momentKey
required
string

The moment key

Request Body schema: application/json
object

The score information associated with this moment in time. Must contain the timeStamp field but be may otherwise contain any other sport-specific score information. The timeStamp and key fields are reserved field names in the score object

Array of objects (Player)

Player information

metadata
object

A dictionary of custom fields. Its JSON string representation (UTF-8) may not exceed 500 bytes. Keys may not contain the following characters . $ # [ ] /

Responses

Request samples

Content type
application/json
{
  • "score": {
    },
  • "players": [
    ],
  • "metadata": { }
}