1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
//! notion-rs: Rust Wrappers around the Notion.so note-taking application. //! --- //! This crate provides useful wrappers and Notion's unofficial API. //! //! > **This crate has not been yet updated for the upcoming offical API release!** //! //! Once this API is released, you'll be able to perform authorization, reads, and writes valid notion workspaces. //! //! For now, if you have your TokenV2, then you too can read and write to a notion workspace. //! //! ```ignore //! #[async_std::main] //! async fn main() { //! // Don't commit your token to git! //! let token = std::env::var("NOTION_TOKEN_V2").unwrap(); //! //! let mut client = notion_rs::builder(token.as_str()).build(); //! //! let blocks = client //! .get_page("https://www.notion.so/157765353f2c4705bd45474e5ba8b46c") //! .await //! .unwrap(); //! //! println!("{:#?}", blocks); //! } //! ``` //! //! //! ## Usage //! Most functionality of this crate is managed by the NotionClient, NotionQuery, and NotionBlock. //! //! - [`NotionBlock`]: A single block in a notion workspace. Has an enum-based type //! - [`NotionQuery`]: Craft HTTP queries to the Notion API endpoint. //! - [`NotionClient`]: Wrap a Reqwest HTTP client with functionaity mod block; mod cfg; mod error; mod query; mod util; #[cfg(feature = "client")] mod client; // innerludes are cool, eh? pub(crate) mod innerlude { pub use crate::block::raw::{BlockMap, GetBlocksResponse}; pub use crate::block::NotionBlock; pub use crate::error::{Error, Result}; pub use crate::query::NotionQuery; pub use crate::NotionEndpoint; } pub use crate::{ block::{BlockData, NotionBlock}, cfg::NotionEndpoint, client::{ClientConfig, NotionClient}, query::NotionQuery, }; /// Create a new ClientBuilder to generate a new `NotionClient /// /// ```ignore /// let mut client = notion_rs::builder(TOKEN).build(); /// let blocks = client.get_page("...").await.unwrap(); /// for block in blocks { /// // do something /// } /// ``` pub fn builder(token_v2: &str) -> ClientConfig { ClientConfig::new(token_v2) }