Pulls data from an Infor CSD FetchWhere API endpoint into a CSV file,
automatically paging through results using the API's RestartRowID
mechanism until the full result set has been retrieved.
- Authenticates against Infor ION using an
.ionapicredentials file (OAuth2 password grant with the file's SAAK/SASK service account credentials). - Calls
SX/rest/serviceinterface/proxy/FetchWherewith the company, operator, table, and where-clause settings fromconfig.ini. - Each response includes a
RestartRowID. The script feeds that value back into the next request and keeps calling until a page comes back empty or the restart ID stops advancing. - All rows returned across every page are combined and written to a single CSV, with column headers taken from the union of fields seen across all rows (some tables return different fields per row).
The record list in the API response is wrapped under a key whose name
depends on the table being queried (e.g. ttbledie for the edie
table), so the script doesn't assume a fixed key — it locates the
list-valued field in the response automatically.
py -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
Place your .ionapi credentials file in config/ and point to it from
config.ini.
Edit config/config.ini:
[ionapi]
; Path to the .ionapi credentials file, relative to this config file or absolute.
file = NSACOM_DEM.ionapi
[fetchwhere]
; These map directly to the FetchWhere request payload.
CompanyNumber = 1000
Operator = sys
TableName = edie
WhereClause =
BatchSize = 500
[output]
; Directory where the resulting CSV file will be written.
directory = ../output- Operator must be a valid operator/user ID on file in the ERP
system (e.g.
sys), not a comparison operator likeEQ. - WhereClause is passed through as-is, e.g.
cono = 1 and errty = 'e'. Leave blank to fetch all rows.
venv\Scripts\python.exe fetch_where.py --config config/config.ini
Output is written to the configured output directory as:
<tenant>_<TableName>_<YYYYmmdd_HHMMSS>.csv
where <tenant> is the ti value from the .ionapi file.
.ionapifiles contain live credentials and are excluded from git via.gitignore— don't commit them.- Large tables can return tens of thousands of rows across hundreds of
pages; there's no built-in row limit, so scope the
WhereClauseif you only need a subset.