在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:perfectmak/pinata-sdk开源软件地址:https://github.com/perfectmak/pinata-sdk开源编程语言:Rust 100.0%开源软件介绍:pinata-sdkThe SetupAdd the crate as a dependency to your codebase [dependencies]
pinata_sdk = "1.1.0" Initializing the APIuse pinata_sdk::PinataApi;
let api = PinataApi::new("api_key", "secret_api_key").unwrap();
// test that you can connect to the API:
let result = api.test_authentication().await;
if let Ok(_) = result {
// credentials are correct and other api calls can be made
} Usage1. Pinning a fileSend a file to pinata for direct pinning to IPFS. use pinata_sdk::{ApiError, PinataApi, PinByFile};
let api = PinataApi::new("api_key", "secret_api_key").unwrap();
let result = api.pin_file(PinByFile::new("file_or_dir_path")).await;
if let Ok(pinned_object) = result {
let hash = pinned_object.ipfs_hash;
} If a directory path is used to construct 2. Pinning a JSON objectYou can send a JSON serializable to pinata for direct pinning to IPFS. use pinata_sdk::{ApiError, PinataApi, PinByJson};
use std::collections::HashMap;
let api = PinataApi::new("api_key", "secret_api_key").unwrap();
// HashMap derives serde::Serialize
let mut json_data = HashMap::new();
json_data.insert("name", "user");
let result = api.pin_json(PinByJson::new(json_data)).await;
if let Ok(pinned_object) = result {
let hash = pinned_object.ipfs_hash;
} 3. UnpinningYou can unpin using the Contribution GuideFeel free to contribute. Please ensure that an issue is exists that describes the feature or bugfix you are planning to contribute. Also, this README is generated using the cargo-readme crate from the LicenseMIT OR Apache-2.0 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论