Using the Sage 100 API to Get Items (with Python examples)

by Endgrate Team 2024-07-18 5 min read

Sage 100 homepage

Introduction to Sage 100 API Integration

Sage 100 is a comprehensive ERP solution designed to streamline business operations, including accounting, inventory management, and customer relationship management. It is widely used by small to medium-sized businesses to enhance efficiency and productivity through its robust features and customizable modules.

Integrating with the Sage 100 API allows developers to access and manipulate data within the Sage 100 system, enabling seamless automation and data synchronization. For example, developers can use the Sage 100 API to retrieve item information, which can be crucial for maintaining accurate inventory records and ensuring smooth supply chain operations.

Setting Up Your Sage 100 Test/Sandbox Account

Before you can start integrating with the Sage 100 API, you'll need to set up a test or sandbox account. This environment allows you to safely experiment with the API without affecting your live data. Follow these steps to get started:

Install and Configure the Sage 100 ODBC Driver

To interact with the Sage 100 API, you must first ensure that the Sage 100 ODBC driver is installed and properly configured on your system. This involves setting up a Data Source Name (DSN) that connects to the Sage 100 ERP system. Here's how to do it:

  • Access the ODBC Data Source Administrator on your system.
  • Create a new DSN that connects to the Sage 100 ERP system using the correct server, database, and authentication settings.
  • Ensure that the Sage 100 ODBC driver is running as either an application or a service, depending on your server configuration.

For detailed instructions, refer to the Sage 100 ODBC Driver Configuration Guide.

Create a Sage 100 Sandbox Environment

Once the ODBC driver is configured, you can set up a sandbox environment within Sage 100:

  • Log in to your Sage 100 account.
  • Navigate to the Library Master module and select Setup > System Configuration.
  • Enable the Client/Server ODBC Driver under the ODBC Driver tab.
  • Enter the server name or IP address where the ODBC application or service is running.
  • Test the ODBC data source to ensure the connection is successful.

This sandbox environment will allow you to test API calls without impacting your production data.

Generate API Credentials for Sage 100

To authenticate API requests, you'll need to generate the necessary credentials:

  • Access the Sage 100 system and navigate to the appropriate module for API access.
  • Follow the instructions to create an API user and generate the required credentials, such as API keys or tokens.
  • Store these credentials securely, as they will be used in your API requests.

With your sandbox environment and credentials set up, you're ready to start making API calls to Sage 100.

Sage 100 authentication documentation page.
sbb-itb-96038d7

Making API Calls to Retrieve Items from Sage 100 Using Python

To interact with the Sage 100 API and retrieve item data, you'll need to use Python along with the ODBC driver. This section will guide you through the process of setting up your Python environment, writing the code to make API calls, and handling the responses.

Setting Up Your Python Environment for Sage 100 API Integration

Before making API calls, ensure you have the necessary Python version and libraries installed:

  • Python 3.11.1 or later
  • ODBC library for Python (such as pyodbc)

Install the pyodbc library using pip:

pip install pyodbc

Writing Python Code to Connect and Retrieve Items from Sage 100

Once your environment is set up, you can write the Python script to connect to the Sage 100 database and retrieve item information. Below is an example script:

import pyodbc

# Define the DSN and credentials
dsn = 'Your_DSN_Name'
user = 'Your_Username'
password = 'Your_Password'

# Establish a connection to the Sage 100 database
connection = pyodbc.connect(f'DSN={dsn};UID={user};PWD={password}')

# Create a cursor object to execute SQL queries
cursor = connection.cursor()

# Define the SQL query to retrieve items
query = "SELECT * FROM CI_Item"

# Execute the query
cursor.execute(query)

# Fetch and print the results
for row in cursor.fetchall():
    print(row)

# Close the connection
connection.close()

Replace Your_DSN_Name, Your_Username, and Your_Password with your actual DSN and credentials.

Verifying Successful API Calls and Handling Errors

After running the script, verify the output to ensure the items are retrieved correctly. If the connection or query fails, handle exceptions using try-catch blocks to manage errors gracefully:

try:
    # Connection and query code here
except pyodbc.Error as e:
    print("Error: ", e)
finally:
    connection.close()

Check your Sage 100 sandbox environment to confirm that the data matches the retrieved items.

For more detailed information on configuring the ODBC driver, refer to the Sage 100 ODBC Driver Configuration Guide.

Sage 100 API call documentation page.

Conclusion and Best Practices for Sage 100 API Integration

Integrating with the Sage 100 API using Python allows developers to efficiently access and manage data within the Sage 100 ERP system. By following the steps outlined in this guide, you can set up your environment, make API calls, and handle responses effectively.

Best Practices for Secure and Efficient Sage 100 API Usage

  • Secure Credential Storage: Always store API credentials securely, using environment variables or secure vaults, to prevent unauthorized access.
  • Handle Rate Limiting: Be aware of any rate limits imposed by the Sage 100 API and implement retry logic or backoff strategies to handle rate limit errors gracefully.
  • Data Transformation: Standardize and transform data fields as needed to ensure consistency across different systems and applications.
  • Error Handling: Implement robust error handling to manage exceptions and ensure your application can recover gracefully from failures.

Streamline Your Integrations with Endgrate

While integrating with Sage 100 can be straightforward, managing multiple integrations can become complex and time-consuming. Endgrate offers a unified API solution that simplifies integration processes, allowing you to focus on your core product development.

With Endgrate, you can:

  • Save time and resources by outsourcing integrations.
  • Build once for each use case instead of multiple times for different platforms.
  • Provide an intuitive integration experience for your customers.

Explore how Endgrate can enhance your integration strategy by visiting Endgrate.

Read More

Ready to get started?

Book a demo now

Book Demo