Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to query archived/in_trash items #524

Open
AlbertMarashi opened this issue Aug 18, 2024 · 4 comments
Open

No way to query archived/in_trash items #524

AlbertMarashi opened this issue Aug 18, 2024 · 4 comments

Comments

@AlbertMarashi
Copy link

Report bugs here only for the Node JavaScript library.

If you're having problems using Notion's API, or have any other feedback about the API including feature requests for the JavaScript library, please email support at [email protected].

Describe the bug
A clear and concise description of what the bug is.

There is currently no documented feature to query pages by whether they are in the trash. This is a quite essential feature for our usecase for syncing data.

@AlbertMarashi
Copy link
Author

AlbertMarashi commented Aug 18, 2024

The API contains the following interface:

type QueryDatabaseBodyParameters = {
    sorts?: Array<{
        property: string;
        direction: "ascending" | "descending";
    } | {
        timestamp: "created_time" | "last_edited_time";
        direction: "ascending" | "descending";
    }>;
    filter?: {
        or: Array<PropertyFilter | TimestampCreatedTimeFilter | TimestampLastEditedTimeFilter | {
            or: Array<PropertyFilter>;
        } | {
            and: Array<PropertyFilter>;
        }>;
    } | {
        and: Array<PropertyFilter | TimestampCreatedTimeFilter | TimestampLastEditedTimeFilter | {
            or: Array<PropertyFilter>;
        } | {
            and: Array<PropertyFilter>;
        }>;
    } | PropertyFilter | TimestampCreatedTimeFilter | TimestampLastEditedTimeFilter;
    start_cursor?: string;
    page_size?: number;
    archived?: boolean;
    in_trash?: boolean;
};

But deleted items are not returned from the trash? Does my integration not have enough permissions? There appears to be no way to invite an integration to the trash...

@AlbertMarashi
Copy link
Author

I imagine this is a bug, because the "archived" property has no effect..

@leandroz
Copy link

I agree it is a bug in the type interface as what you are saying is correct, there is no way right now to query for archived items.

You can go and upvote the feature requests here: https://notiondevs.notion.site/Developer-Feedback-for-Notion-API-bd8874dde623497485ba0f412bce8767

@AlbertMarashi
Copy link
Author

I ended up looking at how notion's deleted search functionality works within the app, hopefully my user token doesn't expire

const data = await fetch("https://www.notion.so/api/v3/search",{
        method: "POST",
        body: JSON.stringify({
            "type": "BlocksInSpace",
            "query": "",
            "filters": {
                "isDeletedOnly": true,
                "excludeTemplates": true,
                "navigableBlockContentOnly": false,
                "requireEditPermissions": false,
                "includePublicPagesWithoutExplicitAccess": false,
                "ancestors": [
                    "YOUR_TABLE_ID"
                ],
                "createdBy": [],
                "editedBy": [],
                "lastEditedTime": {},
                "createdTime": {},
                "inTeams": []
            },
            "sort": {
                "field": "lastEdited",
                "direction": "desc"
            },
            "limit": 100,
            "spaceId": "YOUR_SPACE_ID",
            "source": "trash"
        }),
        headers: {
            "Content-Type": "application/json",
            "Cookie": USER_TOKEN
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants