1 stable release

new 1.0.8 May 7, 2025
1.0.5 Nov 4, 2024
1.0.4 Sep 22, 2024
1.0.2 Jul 18, 2024
0.1.9 Feb 20, 2024

#511 in Web programming

Download history 10/week @ 2025-01-29 66/week @ 2025-02-05 66/week @ 2025-02-12 13/week @ 2025-02-19 58/week @ 2025-02-26 91/week @ 2025-03-05 23/week @ 2025-03-12 8/week @ 2025-03-19 9/week @ 2025-03-26 34/week @ 2025-04-02 16/week @ 2025-04-09 101/week @ 2025-04-16 52/week @ 2025-04-23 64/week @ 2025-04-30

245 downloads per month
Used in notion2md

MIT license

115KB
3.5K SLoC

notion-client

Build Notion API Crates.io

A Rust client library for the Notion API. Supports (almost) all endpoints — everything except authentication, for now!

⚡️ The only Rust crate that is actively maintained and always up-to-date with the latest Notion API version.

Features

  • ✅ Supports databases, pages, blocks, users, comments, and search endpoints
  • 🔒 Thread-safe client
  • 🧰 Builder pattern support
  • 📝 Rich set of examples
  • 🚀 Actively maintained and growing!
  • 🔄 Always in sync with the latest Notion API updates

Getting Started

Example for Query a Database

Corresponding Notion API: Query a database


use notion_client::endpoints::{
    databases::query::request::{QueryDatabaseRequest, Sort, SortDirection, Timestamp},
    Client,
};

const NOTION_DB_ID: &str = ""; // ⚠️ Set your DB id which can be accessible from API
const NOTION_TOKEN: &str = ""; // ⚠️ Set your notion token

#[tokio::main]
async fn main() {
    // Initialize client
    let client = Client::new(NOTION_TOKEN.to_string(), None);
    let Ok(client) = client else {
        panic!("error");
    };

    // Set up request parameters
    let request = QueryDatabaseRequest {
        sorts: Some(vec![Sort::Timestamp {
            timestamp: Timestamp::CreatedTime,
            direction: SortDirection::Ascending,
        }]),
        ..Default::default()
    };

    // Send request
    let res = client
        .databases
        .query_a_database(NOTION_DB_ID, request)
        .await;

    // See result
    print!("{:#?}", res);
}

👉 See more examples

Roadmap

  • Thread-safe support
  • More examples
  • Support blocks endpoint
  • Support pages endpoint
  • Support databases endpoint
  • Support users endpoint
  • Support comments endpoint
  • Support search endpoint
  • Support authentication endpoint
  • Add tests to blocks endpoint
  • Add tests to pages endpoint
  • Add tests to databases endpoint
  • Add tests to users endpoint
  • Add tests to comments endpoint
  • Add tests to search endpoint
  • Support builder pattern

Feel free to suggest new features or improvements! 🙌

Contributing

Contributions are welcome and appreciated! ❤️

If you have an idea:

  • Please open an issue first to discuss it. This ensures no effort is wasted.
  • If there’s already an open issue, feel free to grab it and start contributing!

Here’s our Contributing Guide.

Let’s make this library even better together!

License

This project is licensed under the MIT License.

FAQ

Q: Is authentication supported? A: Not yet — it's on our roadmap!

Q: Is this an official Notion SDK? A: No, this is a community-driven open-source library.

Q: How is this different from other crates? A: This is the only Rust crate actively maintained and updated to match the latest Notion API versions. If you want up-to-date support, you’re in the right place!

Support

If you find this library useful:

  • ⭐ Star this repository
  • 📢 Share it with fellow Rustaceans
  • 🤝 Contribute back!

Dependencies

~6–22MB
~264K SLoC