Name | sf-report-fetcher JSON |
Version |
0.1.0
JSON |
| download |
home_page | None |
Summary | A Python utility to fetch complete Salesforce reports, bypassing the 2000-row limit. Supports custom API versions. |
upload_time | 2025-02-04 11:32:10 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
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. |
keywords |
salesforce
report
api
pagination
salesforce-api
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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!
Raw data
{
"_id": null,
"home_page": null,
"name": "sf-report-fetcher",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "salesforce, report, api, pagination, salesforce-api",
"author": null,
"author_email": "Your Name <your.email@example.com>",
"download_url": "https://files.pythonhosted.org/packages/4b/fd/62c7a62edae82ba4900f8d9d5547ff6b7d18a48445d18697259154199758/sf_report_fetcher-0.1.0.tar.gz",
"platform": null,
"description": "# sf-report-fetcher\n\nA Python utility to fetch complete Salesforce reports, bypassing the 2000-row limit using smart pagination.\n\n## The Problem\n\nSalesforce'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.\n\n## The Solution\n\nThis package implements a smart pagination strategy using column-based filtering. Instead of using offset pagination (which Salesforce doesn't support), it:\n\n1. Fetches the first batch of data\n2. Uses the last value of a specified column as a filter\n3. Fetches the next batch where the column value is greater than the last seen value\n4. Repeats until all data is retrieved\n\n## Installation\n\n```bash\npip install sf-report-fetcher\n```\n\n## Basic Usage\n\n```python\nfrom salesforce_report_fetcher import SalesforceReportFetcher\n\n# Initialize the fetcher\nfetcher = SalesforceReportFetcher(\n access_token=\"your_salesforce_access_token\",\n instance_url=\"https://your-instance.salesforce.com\"\n)\n\n# Fetch all data from a report\nreport_id = \"00OxxxxxxxxxxxxxxxxX\" # Your Salesforce report ID\nid_column = \"Id\" # Any ordered column in your report (usually Id or CreatedDate)\n\n# Get the data\ncolumns, rows = fetcher.fetch_all_report_data(report_id, id_column)\n\n# Work with the data\nprint(f\"Retrieved {len(rows)} rows\")\nfor row in rows:\n for col_name, value in zip(columns, row):\n print(f\"{col_name}: {value}\")\n```\n\n## Advanced Usage\n\n### Specifying Salesforce API Version\n\nYou can specify which Salesforce API version to use:\n\n```python\n# Use specific API version\nfetcher = SalesforceReportFetcher(\n access_token=\"your_token\",\n instance_url=\"https://instance.salesforce.com\",\n api_version=\"47.0\" # Specify your desired API version\n)\n```\n\n### Getting Report Metadata\n\n```python\n# Get report metadata (cached)\nmetadata = fetcher.get_metadata(report_id)\nprint(\"Available fields:\", [field['label'] for field in metadata['reportType']['fields']])\n```\n\n### Executing Reports with Custom Metadata\n\n```python\n# Execute report with custom metadata\ncustom_metadata = {\n \"reportFilters\": [\n {\n \"column\": \"CreatedDate\",\n \"operator\": \"greaterThan\",\n \"value\": \"2024-01-01\"\n }\n ]\n}\nresults = fetcher.execute_report(report_id, custom_metadata)\n```\n\n## Configuration Options\n\n| Parameter | Description | Default |\n|-----------|-------------|---------|\n| `access_token` | Your Salesforce access token | Required |\n| `instance_url` | Your Salesforce instance URL | Required |\n| `api_version` | Salesforce API version to use | \"57.0\" |\n\n## Requirements\n\n- Python 3.7+\n- requests\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nMIT License - feel free to use this in your projects!\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2024 Your Name\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.",
"summary": "A Python utility to fetch complete Salesforce reports, bypassing the 2000-row limit. Supports custom API versions.",
"version": "0.1.0",
"project_urls": {
"Documentation": "https://github.com/hardiksondagar/sf-report-fetcher#readme",
"Homepage": "https://github.com/hardiksondagar/sf-report-fetcher",
"Issues": "https://github.com/hardiksondagar/sf-report-fetcher/issues",
"Repository": "https://github.com/hardiksondagar/sf-report-fetcher.git"
},
"split_keywords": [
"salesforce",
" report",
" api",
" pagination",
" salesforce-api"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "f16c9ab068cdeb0c58f932a86d23e71201d158d28b94825550af9143fe90b876",
"md5": "b97a71983b1cfc4ebc2b5d47da9ea1ad",
"sha256": "0ea07241c0a2ab577122b254865d7e2aa51b92d7bd7968713c5a8000a4b30671"
},
"downloads": -1,
"filename": "sf_report_fetcher-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b97a71983b1cfc4ebc2b5d47da9ea1ad",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 6791,
"upload_time": "2025-02-04T11:32:09",
"upload_time_iso_8601": "2025-02-04T11:32:09.255944Z",
"url": "https://files.pythonhosted.org/packages/f1/6c/9ab068cdeb0c58f932a86d23e71201d158d28b94825550af9143fe90b876/sf_report_fetcher-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4bfd62c7a62edae82ba4900f8d9d5547ff6b7d18a48445d18697259154199758",
"md5": "028552e1244716aeee103762b2381e54",
"sha256": "07605a194206bc4d3e60dfe002d99c3d66a7c2603c2a1ec9fcd8e0143857893b"
},
"downloads": -1,
"filename": "sf_report_fetcher-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "028552e1244716aeee103762b2381e54",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 6670,
"upload_time": "2025-02-04T11:32:10",
"upload_time_iso_8601": "2025-02-04T11:32:10.855308Z",
"url": "https://files.pythonhosted.org/packages/4b/fd/62c7a62edae82ba4900f8d9d5547ff6b7d18a48445d18697259154199758/sf_report_fetcher-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-04 11:32:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hardiksondagar",
"github_project": "sf-report-fetcher#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "sf-report-fetcher"
}