Skip to content
🐹 Go library for the JW Platform API
Go Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Initial release (#1) Dec 3, 2019
.gitignore Initial commit Nov 30, 2019
.travis.yml Increase test coverage (#6) Dec 8, 2019
CHANGELOG.md Add Upload method (#5) Dec 7, 2019
LICENSE Initial commit Nov 30, 2019
Makefile
README.md Update README.md Dec 10, 2019
client.go Add godoc and build badges (#8) Dec 8, 2019
client_test.go Increase test coverage (#6) Dec 8, 2019
go.mod Update go.mod Jan 13, 2020
go.sum
upload.go Increase test coverage (#6) Dec 8, 2019
upload_test.go Increase test coverage (#6) Dec 8, 2019

README.md

Go JW Platform

GoDoc Build Status

The official Go client library for accessing the JW Platform API.

Requirements

Go 1.13+

Installation

Install jwplatform-go with:

go get -u github.com/jwplayer/jwplatform-go

Using Go modules

module github.com/my/package

require (
    github.com/jwplayer/jwplatform-go v0.2.0
)

Usage

import (
  "github.com/jwplayer/jwplatform-go"
)

client := jwplatform.NewClient("API_KEY", "API_SECRET")

Example: Get video metadata

package main

import (
  "context"
  "fmt"
  "log"
  "net/http"
  "net/url"
  "os"

  "github.com/jwplayer/jwplatform-go"
)

func main() {
  ctx, cancel := context.WithCancel(context.Background())
  defer cancel()

  apiKey := os.Getenv("JWPLATFORM_API_KEY")
  apiSecret := os.Getenv("JWPLATFORM_API_SECRET")

  client := jwplatform.NewClient(apiKey, apiSecret)

  // set URL params
  params := url.Values{}
  params.Set("video_key", "VIDEO_KEY")  // some video key, e.g. gIRtMhYM

  // declare an empty interface
  var result map[string]interface{}

  err := client.MakeRequest(ctx, http.MethodGet, "/videos/show/", params, &result)

  if err != nil {
  	log.Fatal(err)
  }

  fmt.Println(result["status"])  // ok
}

Example: Upload video

package main

import (
  "context"
  "fmt"
  "log"
  "net/url"
  "os"

  "github.com/jwplayer/jwplatform-go"
)

func main() {
  filepath := "path/to/your/video.mp4"

  ctx, cancel := context.WithCancel(context.Background())
  defer cancel()

  // set URL params
  params := url.Values{}
  params.Set("title", "Your video title")
  params.Set("description", "Your video description")

  apiKey := os.Getenv("JWPLATFORM_API_KEY")
  apiSecret := os.Getenv("JWPLATFORM_API_SECRET")

  client := jwplatform.NewClient(apiKey, apiSecret)

  // declare an empty interface
  var result map[string]interface{}

  // upload video using direct upload method
  err := client.Upload(ctx, filepath, params, &result)

  if err != nil {
  	log.Fatal(err)
  }

  fmt.Println(result["status"])  // ok
}

Supported operations

All API methods documentated on the API are available in this client. Please refer to our api documentation.

Test

Before running the tests, make sure to grab all of the package's dependencies:

go get -t -v

Run all tests:

make test

For any requests, bug or comments, please [open an issue][issues] or [submit a pull request][pulls].

License

JW Platform API Go library is distributed under the Apache v2.0 license.

You can’t perform that action at this time.