10000 GitHub - RomanBrodetski/notion-client at v0.1.13
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

RomanBrodetski/notion-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

notion-client

Build Notion API Crates.io

Notion API client library for rust. Now, this library supports all endpoints except authentication!

Getting Started

Example for Query a Database

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

const NOTION_ARTICLES_DB_ID: &str = "";
const NOTION_TOKEN: &str = "";

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

    // Set up request parameters
    let request = QueryDatabaseRequest {
        filter: Some(Filter::Value {
            filter_type: FilterType::Property {
                property: "status".to_string(),
                condition: PropertyCondition::Select(SelectCondition::Equals(
                    "article".to_string(),
                )),
            },
        }),
        sorts: Some(vec![Sort::Timestamp {
            timestamp: Timestamp::CreatedTime,
            direction: SortDirection::Ascending,
        }]),
        ..Default::default()
    };

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

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

TODO

  • support threadsafe
  • add more examples
  • support blocks endpoint
  • support pages endpoint
  • support databases endpoint
  • support users endpoint
  • support comments endpoint
  • support search endpoint
  • support authentication endpoint
  • add test to blocks endpoint
  • add test to pages endpoint
  • add test to databases endpoint
  • add test to users endpoint
  • add test to comments endpoint
  • add test to search endpoint
  • support builder pattern

Contributing

Contributions are always welcome! If you have an idea, it's best to float it by us before working on it to ensure no effort is wasted. If there's already an open issue for it, knock yourself out.

If you have any questions, feel free to use Discussions. Please don't hesitate to ask questions!

About

A Notion API Client for Rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 99.3%
  • Other 0.7%
0