#webauthn #cryptography #turnkey #api-client #client

turnkey_client

A Rust client to interact with the Turnkey API

1 unstable release

0.0.2 May 10, 2025

#247 in HTTP client

Download history 130/week @ 2025-05-10 10/week @ 2025-05-17 5/week @ 2025-05-24 22/week @ 2025-05-31 139/week @ 2025-06-07 233/week @ 2025-06-14 193/week @ 2025-06-21 214/week @ 2025-06-28

785 downloads per month

Apache-2.0

365KB
8K SLoC

turnkey_client

This crate contains an HTTP client to interact with the Turnkey API (documentation).

Usage

To make a request to Turnkey:

use turnkey_api_key_stamper::TurnkeyP256ApiKey;
use turnkey_client::generated::SignRawPayloadIntentV2;
use turnkey_client::generated::immutable::common::v1::HashFunction;
use turnkey_client::generated::immutable::common::v1::PayloadEncoding;

// You can load your API key from a file or from env
let api_key = TurnkeyP256ApiKey::from_strings("<private key hex>", None).expect("api key creation failed");

// Create a new client:
let client = turnkey_client::TurnkeyClient::builder().api_key(api_key).build().expect("client builder failed");

// Make a request (for example, a signature request)
let request = client.sign_raw_payload(
    "your-turnkey-organization-id".to_string(),
    client.current_timestamp(),
    SignRawPayloadIntentV2 {
        sign_with: "0x123456".to_string(), // Turnkey address
        payload: "hello from TKHQ".to_string(),
        encoding: PayloadEncoding::TextUtf8,
        hash_function: HashFunction::Keccak256, // assuming ETH
    },
);

// You can then call `request.await?` to get the signature result

Advanced usage

The Turnkey client uses reqwest under the hood. To access the reqwest builder, use the following:

use turnkey_api_key_stamper::TurnkeyP256ApiKey;

let api_key = TurnkeyP256ApiKey::generate();

let client = turnkey_client::TurnkeyClient::builder()
    .api_key(api_key)
    .with_reqwest_builder(|b| b.connection_verbose(true));

Dependencies

~10–22MB
~321K SLoC