0

I'm writing a python script that has to get data about some individuals(phone numbers) from Notion database. I did that part. The problem is that every person has its own database about the weekly progress and I have to retrieve some data from this inner database.

I wrote a script for the first part. Using database id and integration token I can access the outer database and get phone numbers. Each person has a property with URL that contains a database id of inner database. I have a function get_pages().

def get_pages():
    url = f"https://api.notion.com/v1/databases/{DATABASE_ID}/query"

    payload = {"page_size": 1}
    response = requests.post(url, json=payload, headers=headers)

    data = response.json()

    import json
    with open('db.json', 'w', encoding='utf8') as f:
       json.dump(data, f, ensure_ascii=False, indent=4)

    results = data["results"]
    return results

Then I call get_pages() and iterate over the pages. Take phone number and URL. Now I have no idea how to access the inner database. I tried to call get_pages() again and pass as an argument the inner database id, but it doesn't work.

deceze
  • 510,633
  • 85
  • 743
  • 889
sahara
  • 13
  • 3

0 Answers0