CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-airbyte-source-xero

Airbyte source connector for extracting data from the Xero accounting API with support for 21 data streams and incremental sync capabilities

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

core-connector.mddocs/

Core Connector API

Main connector functionality providing the primary interface for Airbyte framework integration. The SourceXero class serves as the entry point for all connector operations including connection validation, stream discovery, and data extraction.

Capabilities

Source Connector Class

The main connector class that inherits from Airbyte's YamlDeclarativeSource, providing all standard Airbyte source functionality with Xero-specific configuration.

from typing import Tuple
from airbyte_cdk.sources.declarative.yaml_declarative_source import YamlDeclarativeSource

class SourceXero(YamlDeclarativeSource):
    """
    Main Airbyte source connector for Xero API.
    
    Inherits from YamlDeclarativeSource to provide declarative configuration
    support using manifest.yaml for stream definitions.
    """
    
    def __init__(self):
        """
        Initialize the Xero source connector.
        
        Automatically loads configuration from manifest.yaml file in the
        source_xero package directory.
        """
    
    def check_connection(self, logger, config: dict) -> Tuple[bool, str]:
        """
        Test connection to Xero API using provided configuration.
        
        Args:
            logger: Python logger instance for diagnostic output
            config (dict): Connection configuration containing access_token,
                         tenant_id, and start_date
        
        Returns:
            Tuple[bool, str]: (success_status, error_message)
                            - (True, None) for successful connection
                            - (False, error_details) for failed connection
        
        Raises:
            Various HTTP and authentication exceptions based on Xero API response
        """
    
    def streams(self, config: dict) -> list:
        """
        Discover and return all available data streams for the connector.
        
        Args:
            config (dict): Connection configuration
            
        Returns:
            list: List of configured stream objects (21 total streams)
                 Each stream object contains metadata, schema, and sync methods
        """

Entry Point Function

Command-line entry point function that initializes the connector and launches it through Airbyte's framework.

def run():
    """
    Main entry point for running the Xero source connector.
    
    Creates a SourceXero instance and launches it using Airbyte CDK's
    launch function with command-line arguments from sys.argv.
    
    This function is registered as the 'source-xero' console script
    in the package's pyproject.toml configuration.
    
    Usage:
        Called automatically when running 'source-xero' command or
        when executing the main.py module directly.
    """

Usage Examples

Basic Connector Initialization

from source_xero import SourceXero
import logging

# Create logger
logger = logging.getLogger(__name__)

# Initialize connector
source = SourceXero()

# Configuration with required fields
config = {
    "access_token": "your_xero_access_token_here",
    "tenant_id": "your_xero_tenant_id_here", 
    "start_date": "2023-01-01T00:00:00Z"
}

# Test connection
is_connected, error = source.check_connection(logger, config)
if is_connected:
    print("Successfully connected to Xero API")
else:
    print(f"Connection failed: {error}")

Stream Discovery and Information

from source_xero import SourceXero

source = SourceXero()
config = {
    "access_token": "your_token",
    "tenant_id": "your_tenant", 
    "start_date": "2023-01-01T00:00:00Z"
}

# Get all available streams
streams = source.streams(config)
print(f"Total available streams: {len(streams)}")

# Stream information
for stream in streams:
    print(f"Stream Name: {stream.name}")
    print(f"Primary Key: {getattr(stream, 'primary_key', 'None')}")
    print(f"Supports Incremental: {hasattr(stream, 'incremental_sync')}")
    print("---")

# Expected output includes 21 streams:
# bank_transactions, contacts, credit_notes, invoices, manual_journals,
# overpayments, prepayments, purchase_orders, accounts, bank_transfers,
# employees, items, payments, users, branding_themes, contact_groups,
# currencies, organisations, repeating_invoices, tax_rates, tracking_categories

Command Line Execution

from source_xero.run import run
import sys

# Simulate command line arguments
sys.argv = ['source-xero', 'check', '--config', 'config.json']

# Run the connector
run()  # This will execute the check command

Integration with Airbyte Framework

The SourceXero class integrates seamlessly with Airbyte's standard protocols:

  • Discovery: Automatically exposes 21 pre-configured streams
  • Check Connection: Validates authentication and API access
  • Read Records: Streams data with proper state management
  • Incremental Sync: Supports cursor-based incremental updates
  • Schema Validation: Enforces data types and structure per stream
  • Error Handling: Provides detailed error reporting for debugging

The connector follows Airbyte's declarative pattern where stream configuration, authentication, pagination, and data transformation are defined in the manifest.yaml file rather than in Python code.

Install with Tessl CLI

npx tessl i tessl/pypi-airbyte-source-xero

docs

configuration.md

core-connector.md

data-processing.md

data-streams.md

index.md

tile.json