#api #pow #api-client #api-key #websocket #ecdsa #co

powco

Rust Client for Pow.co HTTP & Websockets APIs

4 releases

0.1.3 Feb 10, 2022
0.1.2 Feb 10, 2022
0.1.1 Feb 10, 2022
0.1.0 Feb 10, 2022

#7 in #co

Custom license

10KB
189 lines

Powco API Client Rust

Rust Client for Pow.co HTTP & Websockets APIs

Authentication

Authentication is done via ecdsa key pairs, where some API calls require small payments of Bitcoin

Generating Keys

let keys = powco::Keys::generate();

println!("identifier: {}", keys.identifier);
println!("secret: {}", keys.secret);

Existing Keys

Any valid Bitcoin private key (not HD) and address will work as secret and identifier

Making API Calls

Instantiating Client

use std::env;

let keys = powco::Keys {
  identifier: env::var("POWCO_CLIENT_ID"),
  identifier: env::var("POWCO_CLIENT_SECRET"),
}

let client = powco::Client { keys: keys }

if !client.has_valid_keys() {
  panic!("Invalid API Key Pair")
}

Listing Available Jobs

This call does not require payment

let jobs: Vec{powco::Job} = client.list_available_jobs();

Getting a Job

This call does require payment. Getting a job will allow your boost miner to provide work for the job and claim the coins contained therein.

let job: powco::Job = client.get_job(&job.uid);

Dependencies

~24–36MB
~640K SLoC