Metadata-Version: 2.2
Name: sf-report-fetcher
Version: 0.1.0
Summary: A Python utility to fetch complete Salesforce reports, bypassing the 2000-row limit. Supports custom API versions.
Author-email: Your Name <your.email@example.com>
License: MIT License
        
        Copyright (c) 2024 Your Name
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/hardiksondagar/sf-report-fetcher
Project-URL: Documentation, https://github.com/hardiksondagar/sf-report-fetcher#readme
Project-URL: Repository, https://github.com/hardiksondagar/sf-report-fetcher.git
Project-URL: Issues, https://github.com/hardiksondagar/sf-report-fetcher/issues
Keywords: salesforce,report,api,pagination,salesforce-api
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests<3.0.0,>=2.22.0
Dynamic: requires-python

# sf-report-fetcher

A Python utility to fetch complete Salesforce reports, bypassing the 2000-row limit using smart pagination.

## The Problem

Salesforce's Report API has a limitation where it won't return more than 2000 rows per request. While there are various workarounds suggested online (like using multiple reports or offset-based pagination), none of them work reliably for large reports.

## The Solution

This package implements a smart pagination strategy using column-based filtering. Instead of using offset pagination (which Salesforce doesn't support), it:

1. Fetches the first batch of data
2. Uses the last value of a specified column as a filter
3. Fetches the next batch where the column value is greater than the last seen value
4. Repeats until all data is retrieved

## Installation

```bash
pip install sf-report-fetcher
```

## Basic Usage

```python
from salesforce_report_fetcher import SalesforceReportFetcher

# Initialize the fetcher
fetcher = SalesforceReportFetcher(
    access_token="your_salesforce_access_token",
    instance_url="https://your-instance.salesforce.com"
)

# Fetch all data from a report
report_id = "00OxxxxxxxxxxxxxxxxX"  # Your Salesforce report ID
id_column = "Id"  # Any ordered column in your report (usually Id or CreatedDate)

# Get the data
columns, rows = fetcher.fetch_all_report_data(report_id, id_column)

# Work with the data
print(f"Retrieved {len(rows)} rows")
for row in rows:
    for col_name, value in zip(columns, row):
        print(f"{col_name}: {value}")
```

## Advanced Usage

### Specifying Salesforce API Version

You can specify which Salesforce API version to use:

```python
# Use specific API version
fetcher = SalesforceReportFetcher(
    access_token="your_token",
    instance_url="https://instance.salesforce.com",
    api_version="47.0"  # Specify your desired API version
)
```

### Getting Report Metadata

```python
# Get report metadata (cached)
metadata = fetcher.get_metadata(report_id)
print("Available fields:", [field['label'] for field in metadata['reportType']['fields']])
```

### Executing Reports with Custom Metadata

```python
# Execute report with custom metadata
custom_metadata = {
    "reportFilters": [
        {
            "column": "CreatedDate",
            "operator": "greaterThan",
            "value": "2024-01-01"
        }
    ]
}
results = fetcher.execute_report(report_id, custom_metadata)
```

## Configuration Options

| Parameter | Description | Default |
|-----------|-------------|---------|
| `access_token` | Your Salesforce access token | Required |
| `instance_url` | Your Salesforce instance URL | Required |
| `api_version` | Salesforce API version to use | "57.0" |

## Requirements

- Python 3.7+
- requests

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

MIT License - feel free to use this in your projects!
