Crates.io | stellar-client |
lib.rs | stellar-client |
version | 0.1.2 |
source | src |
created_at | 2018-04-20 21:50:12.29966 |
updated_at | 2018-08-20 21:54:31.004413 |
description | A client interface to the stellar Horizon API |
homepage | https://github.com/kbacha/stellar-sdk |
repository | https://github.com/kbacha/stellar-sdk |
max_upload_size | |
id | 61627 |
size | 396,057 |
A lightweight client SDK for the stellar horizon api. Written in rust.
The SDK provides a client and modeled resources to the stellar horizon api. The resources are strictly typed and parse directly from the api. It also provides a robust CLI for managing and introspecting the network.
This repository is broken into multiple crates. Each crate is designed to be used as a different component. The crates are organized as a virtual workspace so that they can be built together and tested at once.
The client provides two interfaces. One is the synchronous client and the other is the asynchronous client. Both consume an IntoRequest trait and will return the appropriate response associated with the endpoint implementation. You should see the documentation associated with the code itself since there are active doctests available for all endpoints. However, the general gist is that the developer should create an endpoint and then exchange that endpoint for a response from the client:
use stellar_client::sync::Client;
use stellar_client::endpoint::asset;
let client = Client::horizon_test().unwrap();
let endpoint = asset::All::default();
let records = client.request(endpoint).unwrap();
The endpoints module in the client crate houses all the horizon API endpoint definitions. Each struct will define what parameters are required for making requests.
The resources module contains the return values of the various endpoints. These resources are fully documented and can be deserialized from the client. There are many resources in the horizon API and you can read about all of them here.
They are deserialized into types that we think will make using them inside other rust applications easier.
The CLI is a command line utility for querying against the stellar network. To install it clone the repo and run:
cargo install -f --path=cli
You can then use it with:
stellar --help
The CLI is most useful for easily perusing horizon/stellar data without needing to construct curl commands. It is also a working example of how the stellar SDK can be consumed and used.
Setup is managed through cargo. We develop on stable but you should be up-to-date before running tests.
cargo test
To build the documentation locally, just use the doc command:
cargo doc
To build and automatically open the client documentation:
cargo doc -p stellar-client --open
To build and automatically open the resource documentation:
cargo doc -p stellar-resources --open
We welcome contributors! Please see our contributing guide for information on how to contribute to our repo!