Using IFS APIs from Python: A Practical Integration Starter
A hands-on guide to calling IFS Cloud OData endpoints from Python — token handling, CRUD operations, pagination, and pulling purchase orders into a pandas DataFrame.
Published
IFS Cloud shifts the supported external integration boundary away from direct database calls toward documented projection APIs and other managed interfaces. For developers and data engineers accustomed to calling PL/SQL directly, OData can feel unfamiliar—but Python's HTTP libraries make it accessible. This guide walks through OAuth token management, CRUD operations, pagination, and a practical template for pulling purchase orders into a pandas DataFrame.
Why Python for IFS APIs?
IFS Cloud exposes a broad public API surface through OData (Open Data Protocol), alongside files, events, Connect and other supported integration mechanisms. Python's ecosystem is ideal for projection APIs:
- requests library handles HTTP calls elegantly
- OAuth2 libraries streamline token acquisition
- pandas seamlessly converts API responses into DataFrames
- No proprietary connectors needed—plain HTTP and JSON
Unlike the legacy PL/SQL approach, which required session management and direct database access, OData is stateless. Each request stands alone, which simplifies integration but requires rethinking how you structure multi-step operations.
Understanding IFS Cloud Authentication
IFS Cloud uses OAuth 2.0/OIDC. Client credentials is a common service-to-service grant where it is enabled for the registered client; use the exact grant, scopes and endpoints configured for your release and tenant. Here's the architecture:
- Your application (service user) authenticates with the IFS Identity and Access Manager (IAM)
- IAM issues an access token (JWT) valid for a limited time
- You attach this token as a Bearer token in subsequent API requests
- The IFS Proxy validates the token and routes your request to the backend
Key difference from legacy: Design new managed-Cloud API integrations around the documented OAuth/OIDC flow, not database credentials or Basic Authentication.
Setting Up OAuth2 Token Management
Before making API calls, you need a reusable token handler. Here's a robust implementation:
This client caches tokens and refreshes them automatically before expiry, eliminating redundant authentication calls.
Making API Calls: GET, POST, PATCH
Now that you have token management sorted, let's build a reusable API client:
IFS business states are commonly controlled by actions. To release, approve, post, cancel, or otherwise transition an ERP object, call the exact action advertised by $metadata; do not assume a writable Status property.
Handling Pagination
OData APIs return results in pages. The key is the @odata.nextLink property—when present, it points to the next page. Here's a generator pattern for clean pagination:
Real-World Example: POs to DataFrame
Here's a detailed template that pulls purchase orders and their line items into pandas DataFrames. Projection, entity-set, key, enumeration and property names vary by IFS Cloud release and installed components; map the illustrative names below to the exact $metadata contract before running it.
The overdue result is deliberately line-grained: a past promised date is not overdue once the ordered quantity is fully received, and cancelled/closed terminal states must be excluded using the exact enumeration values exposed by the target projection. Monetary totals remain separated by currency unless you add a governed conversion rule.
This starter collects all rows in memory. For a large production extract, process and checkpoint one page at a time into a governed staging store, preserve the server continuation until the page is durably written, and reconcile keys/counts. Do not build a multi-million-row list before writing the first byte.
Key Considerations and Best Practices
Statelessness: OData is stateless across requests. An individual projection action can still implement one atomic business operation. For a genuine multi-call workflow, persist progress, make retries idempotent, and use documented cancellation/reversal actions; do not assume DELETE or a status PATCH is a rollback.
Error Handling: Always implement retry logic for network-related failures, but be mindful of rate limits. IFS Cloud may throttle requests, so implement exponential backoff:
Filtering and Selection: Use OData query parameters to reduce data transfer:
$filterfor server-side filtering$selectto return only needed fields$topas a requested initial page size; follow@odata.nextLinkfor continuation rather than manufacturing$skipoffsets$orderbyfor sorting
Example:
Token Security: Store credentials securely:
- Use environment variables:
os.getenv("IFS_CLIENT_SECRET") - Or a secrets management service (AWS Secrets Manager, HashiCorp Vault)
- Never hardcode or commit credentials
Troubleshooting Common Issues
401 Unauthorized: The API did not accept the presented authentication. Check token expiry, issuer/audience, client/principal status, and the discovered IAM endpoints; projection permission problems are commonly reported as 403 instead.
403 Forbidden: The token is valid, but its principal lacks the required projection grant or underlying business-data access. Check the OAuth client/principal mapping and IFS permission sets in the administration pages for your release.
404 Not Found: The OData endpoint path is incorrect. Double-check the projection name and version (e.g., /v1/ vs /v2/).
429 Too Many Requests: Throttling is active. Honour Retry-After when supplied, reduce concurrency, and use exponential backoff. Use $batch only if the target projection explicitly supports it; batching is not a universal escape from throttling.
Large response times: Use $select and $filter to reduce payload size. Avoid fetching all records if you only need a subset.
Conclusion
Python's ecosystem makes IFS Cloud integration straightforward once you understand OAuth token management and OData pagination. The key patterns—token caching, authenticated requests, pagination loops, and DataFrame conversion—apply across most IFS projects.
Start with the OAuth client and API wrapper above, then map it to the metadata and permission model of your environment. The stateless API boundary requires a mindset shift from direct PL/SQL, but it provides a well-defined foundation for modern integrations when its versioned contracts are tested and governed.
Key Takeaways
- OAuth2 is mandatory for IFS Cloud—implement token caching to avoid repeated authentication
- Use OData query parameters (
$filter,$select,$top) to reduce data transfer and improve performance - Pagination with
@odata.nextLinkhandles large result sets elegantly - pandas DataFrames are convenient for bounded analysis; stream large extracts to a governed staging store
- Implement retry logic with exponential backoff for resilient integrations
- Store credentials securely using environment variables or secrets management
- OData is stateless—each request must include full context; don't assume session memory
Need to connect Python services or scripts to IFS APIs?
Syrett Consultancy can help you build robust Python integrations for IFS Cloud with sane authentication and data handling.