Skip to content

forestsource/notion-sdk-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

notion-sdk-rs

A Rust SDK for the Notion API.

Features

  • Strongly-typed Rust interface for the Notion API
  • Async/await support
  • Comprehensive type definitions for Notion's data structures
  • Error handling with custom error types
  • Support for all major Notion API endpoints

Installation

Add this to your Cargo.toml:

[dependencies]
notion-sdk-rs = "0.1.0"

Usage

use notion_sdk_rs::{NotionClient, Error};
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Error> {
    // Initialize the client with your Notion API token
    let client = NotionClient::new("your-notion-api-token")?;

    // Get a page
    let page = client.get_page("page-id").await?;
    println!("Page title: {:?}", page.properties.get("title"));

    // Query a database
    let query = json!({
        "filter": {
            "property": "Status",
            "select": {
                "equals": "Done"
            }
        }
    });
    let database = client.query_database("database-id", &query).await?;
    println!("Database results: {:?}", database);

    // Create a new page
    let new_page = json!({
        "parent": { "database_id": "database-id" },
        "properties": {
            "Name": {
                "title": [
                    {
                        "text": {
                            "content": "New page"
                        }
                    }
                ]
            }
        }
    });
    let created_page = client.create_page(&new_page).await?;
    println!("Created page: {:?}", created_page);

    Ok(())
}

Examples

Check out the examples directory for more usage examples.

API Documentation

For detailed API documentation, run:

cargo doc --open

Features

  • Database operations
    • Query databases
    • Create databases
    • Update databases
  • Page operations
    • Get pages
    • Create pages
    • Update pages
  • Block operations
    • Get blocks
    • Update blocks
    • Delete blocks
    • Get block children
    • Append block children
  • User operations
    • List users
    • Get user
    • Get bot user
  • Search
    • Search pages and databases

CI/CD Setup

This project uses GitHub Actions for Continuous Integration and Continuous Deployment (CI/CD). The CI/CD pipeline is configured to build, test, and lint the project on every push and pull request to the main branch.

GitHub Actions Workflow

The GitHub Actions workflow file is located at .github/workflows/ci.yml. It includes the following steps:

  1. Checkout repository: Checks out the repository to the GitHub Actions runner.
  2. Set up Rust: Sets up the Rust toolchain using actions-rs/toolchain.
  3. Build: Builds the project using cargo build.
  4. Run tests: Runs the tests using cargo test.
  5. Run linter: Runs the linter using cargo clippy.

Running CI/CD Locally

You can also run the CI/CD pipeline locally using the following commands:

# Build the project
cargo build

# Run tests
cargo test

# Run linter
cargo clippy -- -D warnings

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages