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

v2 SDK does not return page properties #334

Closed
teajaymars opened this issue Aug 2, 2022 · 8 comments
Closed

v2 SDK does not return page properties #334

teajaymars opened this issue Aug 2, 2022 · 8 comments

Comments

@teajaymars
Copy link

teajaymars commented Aug 2, 2022

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 developers@makenotion.com.

Describe the bug
When I query a page using the v2.0.0 SDK and above, the responses do not include property values. Just an ID. There's no indication in the documentation that an extra step is required to fetch the page property values.

I'm trying to paginate through a database, but each row contains no property values. It also happens retrieving a single page. I'll write a minimal example:

To Reproduce
Node version: 16.14.0
Notion JS library version: 1.0.4

spec.js:

const { Client } = require('@notionhq/client')

const notion = new Client({ auth: process.env.NOTION_TOKEN })
const page_id = process.env.NOTION_PAGE_ID

notion.pages.retrieve({ page_id }).then((page) => {
  console.log(page.properties)
})

Result (SDK v1.0.4):

{
  Case: { id: '%3BVfS', type: 'files', files: [] },
  Guitar: { id: '%3DkPp', type: 'files', files: [ [Object] ] },
  'Made In': { id: 'O%7BaE', type: 'rich_text', rich_text: [ [Object] ] },
  State: { id: 'PQJs', type: 'rich_text', rich_text: [] },
  Serial: { id: 'WuDR', type: 'rich_text', rich_text: [ [Object] ] },
  Tags: { id: 'ii%5E%7C', type: 'multi_select', multi_select: [ [Object] ] },
  Name: { id: 'title', type: 'title', title: [ [Object] ] }
}

Result (v2.0.0):

{
  Case: { id: '%3BVfS' },
  Guitar: { id: '%3DkPp' },
  'Made In': { id: 'O%7BaE' },
  State: { id: 'PQJs' },
  Serial: { id: 'WuDR' },
  Tags: { id: 'ii%5E%7C' },
  Name: { id: 'title' }
}

Steps to reproduce the behavior:
Run the above script and compare v1.0.4 to 2.0.0 output.

Expected behavior
The SDK should include Notion properties on simple queries.

If this is intentional behaviour: The documentation should make this very obvious! How do I retrieve a full database in the v2 SDK?

@teajaymars
Copy link
Author

Aha. This is apparently intended behaviour! I have found a note halfway down the "page" documentation:

Property values of this page. As of version 2022-06-28, properties only contains the ID of the property; in prior versions properties contained the values as well.

If anyone else gets stuck with this, it looks like this is the way the API is designed. Github issues are probably the wrong forum for feedback about the design changes, but this is an eyebrow-raising decision if ever I've seen one.

Updated issue for the Notion team:

  • There's no mention of this on the Database API documentation page. It still states that the properties field will include the property value.
  • It would be really nice if you'd extend this SDK to do some common tasks, like iterate through the rows of a database and actually get the records of the database?

I'm downgrading to the v1 SDK so I don't have to write as much code. I guess if I want to use V2 I have to write a bunch of code to send 1 round-trip per database cell?

@cosmith
Copy link

cosmith commented Aug 3, 2022

Just to add a data point, moving from API v2022-02-22 to v2022-06-28 makes me go from 2 requests (querying a db with 108 elements to get 12 properties) to 12*108 requests, so about 1300 requests total.

Having a method to get all properties of a page would be more reasonable... I would do one request per db object.

@oliviermadre
Copy link

Same here, downgraded to v1 sdk due to the new way of fetching property value in v2.
I didn't find any way in the SDK v2 to fetch a bunch of pages with their bunch of property values without doing loads of API call (pages x properties).

According to changelog :

For more examples of how to use the retrieve a page property item endpoint, our SDK examples have been updated to use the retrieve a page property item endpoint.

So, the github-sync-project example is supposed to "show us the way" to retrieve property value :

for (const page of pages) {
const issueNumberPropertyId = page.properties["Issue Number"].id
const propertyResult = await notion.pages.properties.retrieve({
page_id: page.id,
property_id: issueNumberPropertyId,
})
issues.push({
pageId: page.id,
issueNumber: propertyResult.number,
})
}

This makes me very sad that the good practice seems to be doing as many API calls as necessary to fetch values.
No bulk method, only "retrieve" that fetch a single property value from a single page.

This SDK version, for bulk use cases, is broken.
Especially when you consider rate limits (average 3 req / sec) from the API documentation.

@laripereira14
Copy link

laripereira14 commented Aug 10, 2022

It's such a shame they've dropped the v1 way of fetching properties. I seriously can't see any benefits with the v2 way.
Since in the Slack channel many people are complaining about it too, let's hope they are going to do something... meanwhile, I'm using v1.

@e-e-e
Copy link

e-e-e commented Aug 11, 2022

This looks like a duplicate of #317

@teajaymars
Copy link
Author

OK, I skimmed past #317 when I filed this. Because it says it's "missing metadata from properties" when my problem was missing data from properties. I accept that's a dupe though.

I don't think this issue is going to get Notion to reconsider their API strategy, but oh boy, a developer can dream. I'll close this issue.

I've filed a simpler issue about the API docs: #336

@oliviertassinari
Copy link

oliviertassinari commented Aug 20, 2022

Could we reopen and consider this a feature request? Considering:

The rate limit for incoming requests is an average of 3 requests per second.

https://developers.notion.com/reference/request-limits#rate-limits

How are we supposed to be able to fetch a database with all the properties of one column? It seems quite a challenge: e.g. #334 (comment)

@laripereira14
Copy link

laripereira14 commented Sep 1, 2022

Good news: it's now possible again to retrieve page properties values when querying a page!
https://developers.notion.com/changelog/changes-for-august-31-2022

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

6 participants