alchemy_api/
lib.rs

1//! A high-level binding for [`Alchemy Enhanced APIs`], written in Rust.
2//!
3//! Alchemy provides a suite of web3 APIs that dramatically simplify and optimize common request
4//! patterns to make your life as a developer easier.
5//!
6//! Access the blockchain like never before with Alchemy's continually expanding Enhanced API
7//! suite, and web3 developer tools! Query NFTs by the user, trace transactions, get real-time
8//! notifications in your dApp, debug smart contracts faster, and do more with Alchemy's supported
9//! endpoints.
10//!
11//! This crate uses the [reqwest] crate for a convenient, higher-level HTTP Client, for request and
12//! response, to and from Alchemy, and [serde] for serialize and deserialize from and to
13//! appropriate data format.
14//!
15//! # Examples
16//!
17//! Let's start out creating an [`AddressActivity`] webhook.
18//!
19//! ```no_run
20//! use alchemy_api::{
21//!     alchemy::Alchemy,
22//!     api::notify::{CreateWebhook, WebhookResponse, WebhookType},
23//!     cores::query::Query,
24//! };
25//!
26//! #[tokio::main]
27//! async fn main() -> anyhow::Result<()> {
28//!     let client = Alchemy::new(&std::env::var("ALCHEMY_TOKEN")?);
29//!
30//!     // Create a simple endpoint.
31//!     let endpoint = CreateWebhook::builder()
32//!         .webhook_url(std::env::var("WEBHOOK_URL")?)
33//!         .webhook_type(WebhookType::AddressActivity)
34//!         .addresses(vec![std::env::var("ADDRESS")?.parse()?])
35//!         .build()?;
36//!     println!("{:?}", endpoint);
37//!
38//!     // Call the endpoint. The return type decides how to represent the value.
39//!     let webhook: WebhookResponse = endpoint.query(&client).await?;
40//!     println!("webhook: {:?}", webhook);
41//!
42//!     anyhow::Ok(())
43//! }
44//! ```
45//!
46//! For more examples, take a look at the `examples/` directory.
47//!
48//! [`Alchemy Enhanced APIs`]: https://docs.alchemy.com/reference/enhanced-apis-overview
49//! [reqwest]: https://crates.io/crates/reqwest
50//! [serde]: https://crates.io/crates/serde
51//! [`AddressActivity`]: self::api::notify::WebhookType#AddressActivity
52
53#![deny(missing_docs)]
54#![warn(missing_debug_implementations, rust_2018_idioms, rustdoc::all)]
55#![allow(rustdoc::private_doc_tests)]
56#![cfg_attr(docsrs, feature(doc_cfg))]
57
58/// Alchemy client module, contains information about Alchemy connection.
59pub mod alchemy;
60/// API module, contains list of API supported by Alchemy.
61pub mod api;
62/// Core module, contains some helpful generic traits for endpoint and request.
63pub mod cores;
64/// Types module, contains some helpers type associated with the data Alchemy provided.
65pub mod types;