# Notion API, how to retrieve the entries in a database

> Learn how to retrieve all entries in a Notion database with the official API by initializing the client and calling notion.databases.query().

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2023-02-12 | Topics: [Tools](https://flaviocopes.com/tags/tools/) | Canonical: https://flaviocopes.com/notion-api-how-to-retrieve-the-entries-in-a-database/

Here’s how to list all entries in a Notion database using the official Notion API.

First you need to have a reference to the Notion instance

```javascript
import { Client } from '@notionhq/client'

//...

const notion = new Client({ auth: process.env.NOTION_API_KEY })
```

Then you can call `notion.database.query()` to retrieve the entries.

This retrieves all entries:

```javascript
const postsReady = await notion.databases.query({
  database_id: process.env.NOTION_DB_ID,
})
```

This retrieves all entries with the checkbox property named “Ready” checked:

```javascript
const postsReady = await notion.databases.query({
  database_id: process.env.NOTION_DB_ID,
  filter: {
    and: [
      {
        property: 'Ready',
        checkbox: {
          equals: true,
        },
      },
    ],
  },
})
```

You can do a lot more.

You can add more filtering rules, combining them with `or` or `and` logic.

You can sort them by a specific property, ascending or descending.

It’s pretty cool.

See the official docs of `notion.databases.query()`: [https://developers.notion.com/reference/post-database-query](https://developers.notion.com/reference/post-database-query)
