Skip to content

gioelecerati/livepeer-rust-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README.md

livepeer-rs

0.0.1

Crate to interact with the Livepeer Studio API

This library provides a Rust interface to interact with the Livepeer API. The main components include the Vod and Task traits, the AccessControlApi struct, and an error module to handle API error responses.

Vod trait

The Vod trait contains the following methods:

  • Get asset details
  • Get a presigned URL for asset upload
  • Upload an asset
  • Get an asset by its ID
  • Get an asset by its Playback ID
  • Get assets by their Content ID (CID)
  • Get assets by User ID
  • Update an asset
  • Import an asset
  • Export an asset to IPFS
  • List webhook subscriptions

All methods return a Result<serde_json::Value, crate::errors::Error> or an appropriate error type.

Task trait

The Task trait provides the following methods for managing tasks:

  • List tasks
  • Get a task by its Output Asset ID
  • Get tasks by User ID

All methods in the Task trait return a Result<serde_json::Value, crate::errors::Error> or an appropriate error type.

AccessControlApi

The AccessControlApi struct offers methods for managing Signing keys:

  • List signing keys
  • Create a signing key
  • Delete a signing key

All methods return a Result<serde_json::Value, errors::Error> or an appropriate error type.

AccessControlApi can be initialized using the new function with a LivepeerClient instance.

Error Handling

The errors module provides an Error enum that represents different API error responses. The from_response function takes a surf::Response and returns a corresponding Error variant. The enum also contains variants for specific Livepeer actions like LISTSTREAMS and CREATESTREAM.

Dependencies

See Cargo.toml for a full list of dependencies.

Documentation

Generate and view the documentation locally by running the following commands:

$ cargo doc
$ cd ./target/doc
$ python3 -m http.server 8080

Open your browser and navigate to http://localhost:8080/livepeer_client

Example usage

use livepeer_rs::{vod::Vod, Livepeer, LivepeerEnv};

fn main() {
    let _env = LivepeerEnv::Prod;

    // Set up your Client
    let lp_client = Livepeer::new(String::from("$YOUR_API_TOKEN"), Some(_env));

    // Retrieve JSON of VOD assets
    match lp_client.asset.list_assets() {
        Ok(assets) => {
            println!("Assets: {}", serde_json::to_string(&assets).unwrap());
        }
        Err(err) => {
            println!("Error retrieving VOD assets: {:?}", err);
        }
    };

    // Retrieve JSON of Livepeer Streams
    match lp_client.stream.list_streams() {
        Ok(streams) => {
            println!("Streams: {}", serde_json::to_string(&streams).unwrap());
        }
        Err(err) => {
            println!("Error retrieving streams: {:?}", err);
        }
    };
}

Docs

https://docs.rs/crate/livepeer-rs/latest

LICENSE

MIT License

Copyright (c) 2022 gioelecerati

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Readme generated by readme-gpt by gioelecerati

About

Livepeer.com API rust client

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages