Giter Club home page Giter Club logo

jwplatform-dotnet's Introduction

JW Platform API

The .NET client library for accessing the JW Platform Management API written in C#.

Requirements

C# 5.0+
.NET Framework 4.5+
.NET Core 1.0+

Installation

This library is available as a Nuget Package.

  • On the project you want to add the library to:

    • Right click "References" -> "Manage Nuget Packages"
    • Search for jwplatform -> Click "Install"
  • On the project you want to add the library to:

    • Right click "Dependencies" -> "Manage Nuget Packages"
    • Search for jwplatform -> Click "Add Package"
  •  dotnet add package jwplatform
    

Methods

The docs for API endpoints can be found in the Supported Operations section below.

Method Use
GetRequestAsync* Fulfilling GET endpoints
GetRequest --
PostRequestAsync* Fulfilling POST endpoints
PostRequest --
UploadRequestAsync* Fulfilling local file uploads
UploadRequest --

*Highly recommended to use async methods if possible.

Usage

Import the jwplatform library:

using jwplatform;

Initialize a new jwplatform API with your API Key and API Secret
(Here is how to find those values):

var jwplatformApi = new Api(API_KEY, API_SECRET);

You can use jwplatformApi to make any API request.

**All request paths need to begin with a / in order to properly execute.

The following are some examples of how to accomplish 4 different types of requests.

Example 1: GET - /videos/show

An example of how to get to information about a video with the Media Id MEDIA_ID.

var jwplatformApi = new Api(API_KEY, API_SECRET);

var requestParams = new Dictionary<string, string> {
	{"video_key", "MEDIA_ID"}
}

// Asynchronously
var response = await jwplatformApi.GetRequestAsync("/videos/show", requestParams);

// Synchronously
var response = jwplatformApi.GetRequest("/videos/show", requestParams);

Example 2: POST w/ Body Parameters - /videos/update

An example of how to update the title and author of a video with the Media Id MEDIA_ID.

var jwplatformApi = new Api(API_KEY, API_SECRET);

var requestParams = new Dictionary<string, string> {
	{"video_key", "MEDIA_ID"},
	{"title", "New Title"},
	{"author", "New Author"}
}

// Asynchronously
var response = await jwplatformApi.PostRequestAsync("/videos/update", requestParams, true);

// Synchronously
var response = jwplatformApi.PostRequest("//videos/update", requestParams, true);

Example 3: POST w/ Query Parameters - /accounts/tags/create

An example of how to create a new video tag on your account.

var jwplatformApi = new Api(API_KEY, API_SECRET);

var requestParams = new Dictionary<string, string> {
	{"name", "New Tag"}
}

// Asynchronously
var response = await jwplatformApi.PostRequestAsync("/accounts/tags/create", requestParams, false);

// Synchronously
var response = jwplatformApi.PostRequest("/accounts/tags/create", requestParams, false);

Example 4: Upload

Uploading files is a two-step process.

  1. A /videos/create call is done to set up the video's info.
    (See here to see the video info properties that can be set)
  2. The video file is uploaded.

For more information on the uploading process, see here.

An example of how to upload a local video file to your account.

var jwplatformApi = new Api(API_KEY, API_SECRET);

var videoInfo = new Dictionary<string, string> {
	{"title", "My Video"},
	{"author", "Me"}
}

var localFilePath = "path/to/video_file.mov";

// Asynchronously
var response = await jwplatformApi.UploadAsync(videoInfo, localFilePath);

// Synchronously
var response = jwplatformApi.UploadRequest(videoInfo, localFilePath);

Test

To run the unit tests, you must have a local copy of the client. You can easily run the tests using Visual Studio by opening the Test Explorer.

If using .NET CLI, run the following command in the root of the project:

dotnet test

Supported Operations

All Management API endpoints are supported. Please refer here.

License

This JW Platform API library is distributed under the Apache 2 License

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

jwplatform-dotnet's People

Contributors

mamaddox avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

isabella232

jwplatform-dotnet's Issues

Extend current video upload API with byte array source

Hello,

At present, you have only file based video upload API:

var localFilePath = "path/to/video_file.mov";

// Asynchronously
var response = await jwplatformApi.UploadAsync(videoInfo, localFilePath);

However, there is a case, when you receive file via some API (like REST) from user, and you want to upload this video to https://www.jwplayer.com/. So, you have no this video on your disk, and you have 2 options. Either you need to save user video to the disk before uploading to jwplayer, or you cannot use jwplatformApi.UploadAsync() API.

I would like to have byte array based upload API. It may looks like this:

byte[] fileBytes = ...
var response = await jwplatformApi.UploadAsync(videoInfo, fileBytes);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.