Airbyte source connector for extracting data from Notion workspaces with OAuth2.0 and token authentication support.
npx @tessl/cli install tessl/pypi-airbyte-source-notion@3.0.0A Python-based Airbyte source connector for integrating with the Notion API. This connector enables data extraction from Notion workspaces, allowing users to sync databases, pages, blocks, users, and comments to their preferred data destinations. Built using Airbyte's declarative low-code CDK framework with custom Python streams for complex operations.
airbyte-integrations/connectors/source-notion/from source_notion import SourceNotion
from source_notion.run import runFor accessing individual stream classes:
from source_notion.streams import (
Pages, Blocks, NotionStream, IncrementalNotionStream,
StateValueWrapper, NotionAvailabilityStrategy, MAX_BLOCK_DEPTH
)
from source_notion.components import (
NotionUserTransformation,
NotionPropertiesTransformation,
NotionDataFeedFilter
)# Display connector specification
source-notion spec
# Test connection
source-notion check --config config.json
# Discover available streams
source-notion discover --config config.json
# Extract data
source-notion read --config config.json --catalog catalog.jsonfrom source_notion import SourceNotion
from airbyte_cdk.models import ConfiguredAirbyteCatalog
# Initialize the connector
source = SourceNotion()
# Configuration with OAuth2.0
config = {
"credentials": {
"auth_type": "OAuth2.0",
"client_id": "your_client_id",
"client_secret": "your_client_secret",
"access_token": "your_access_token"
},
"start_date": "2023-01-01T00:00:00.000Z"
}
# Get available streams
streams = source.streams(config)
# Check connection
connection_status = source.check(logger, config)The connector is built using Airbyte's hybrid architecture combining:
Key components:
Core functionality for setting up and configuring the Notion source connector with authentication and stream management.
class SourceNotion(YamlDeclarativeSource):
def __init__(self): ...
def streams(self, config: Mapping[str, Any]) -> List[Stream]: ...
def _get_authenticator(self, config: Mapping[str, Any]) -> TokenAuthenticator: ...
def run(): ...Base classes and functionality for managing Notion data streams with pagination, error handling, and incremental sync capabilities.
class NotionStream(HttpStream, ABC):
url_base: str
primary_key: str
page_size: int
def backoff_time(self, response: requests.Response) -> Optional[float]: ...
def should_retry(self, response: requests.Response) -> bool: ...
class IncrementalNotionStream(NotionStream, CheckpointMixin, ABC):
cursor_field: str
def read_records(self, sync_mode: SyncMode, stream_state: Mapping[str, Any] = None, **kwargs) -> Iterable[Mapping[str, Any]]: ...Specific stream implementations for extracting different types of data from Notion workspaces, including pages and nested block content.
class Pages(IncrementalNotionStream):
state_checkpoint_interval: int
def __init__(self, **kwargs): ...
class Blocks(HttpSubStream, IncrementalNotionStream):
block_id_stack: List[str]
def stream_slices(self, sync_mode: SyncMode, cursor_field: List[str] = None, stream_state: Mapping[str, Any] = None) -> Iterable[Optional[Mapping[str, Any]]]: ...
def read_records(self, **kwargs) -> Iterable[Mapping[str, Any]]: ...Custom components for transforming Notion API responses and filtering data for efficient incremental synchronization.
class NotionUserTransformation(RecordTransformation):
def transform(self, record: MutableMapping[str, Any], **kwargs) -> MutableMapping[str, Any]: ...
class NotionPropertiesTransformation(RecordTransformation):
def transform(self, record: MutableMapping[str, Any], **kwargs) -> MutableMapping[str, Any]: ...
class NotionDataFeedFilter(RecordFilter):
def filter_records(self, records: List[Mapping[str, Any]], stream_state: StreamState, stream_slice: Optional[StreamSlice] = None, **kwargs) -> List[Mapping[str, Any]]: ...The connector supports flexible authentication methods:
{
"credentials": {
"auth_type": "OAuth2.0",
"client_id": "notion_client_id",
"client_secret": "notion_client_secret",
"access_token": "oauth_access_token"
},
"start_date": "2023-01-01T00:00:00.000Z"
}{
"credentials": {
"auth_type": "token",
"token": "notion_integration_token"
},
"start_date": "2023-01-01T00:00:00.000Z"
}{
"access_token": "notion_token",
"start_date": "2023-01-01T00:00:00.000Z"
}The connector provides access to these Notion API resources:
The connector implements comprehensive error handling for common Notion API scenarios: