-
Notifications
You must be signed in to change notification settings - Fork 1
Documentation
David De Bels edited this page May 23, 2021
·
1 revision
All communication with the Notion API happens by using a NotionClient object. A NotionClient requires an integration token to be able to communicate with the Notion API, see the official Authorization guide for more information on how to create an integration and a token. Multiple NotionClient objects can be used, each using different integration tokens.
Once initialized a NotionClient object can make requests to the Notion API:
- All requests to the Notion API are asynchronous and will return the result (or error) in a completion handler.
- If the request was successful, the response will be returned in the completion handler in the form of one or multiple native objects (e.g. NotionPage or NotionUser). These objects are (often simplified) wrappers around the JSON objects that the Notion API returns. These exist to simplify reading and writing data from/to the Notion API. It should never be necessary to deal with JSON directly.
- If the request has failed, an NSError object will be returned in the completion handler. In case of an API error, the error object's code will be the HTTP status code and the response body containing the error message will be in the userInfo dictionary of the error object.
- Requests that use pagination are handled automatically by default for simplicity sake. If a response indicates that more items are available, a new request will be made to fetch the next page. This means that calling a function on a NotionClient to get a list may do multiple API requests behind the scenes. The completion handler will return the results of all pages. The page size is set to 100 by default (the maximum) but this can be modified.
- At the moment there is no way to handle paginated requests manually but this will be added in the future.