FullStack Labs

Please Upgrade Your Browser.

Unfortunately, Internet Explorer is an outdated browser and we do not currently support it. To have the best browsing experience, please upgrade to Microsoft Edge, Google Chrome or Safari.
Upgrade

Using Stedi to Turn EDI Transactions Into a Json API

Written by 
Jeremy Garner
,
Senior Software Engineer
Using Stedi to Turn EDI Transactions Into a Json API
blog post background
Recent Posts
Google AMP vs. Other Frameworks - When to Use Each
How to Create a Simple File-Transfer WebRTC React Web Application
Using Split Flags with React to Control Feature Deployments

Table of contents

Let’s start with answers to some of the common questions about EDI to help you become more familiar with the EDI format. Afterwards, you’ll learn how one solution, Stedi, can help you build a custom EDI integration.

What is EDI?

EDI (Electronic Data Interchange) was developed in the 1970s with the goal of replacing paper-based business documents and manual data entry with computer-to-computer data exchange. Instead of sending a paper document, EDI allowed computers to send data files.

Today, multiple EDI standards exist and their adoption rates vary by geographic region and industry.  In simple terms, an EDI standard is a list of commonly used business document definitions, where each definition is normally identified with a number or code. For example, the X12 standard is quite broad and includes transportation, health care, insurance, and legal documents among others.

Each document definition describes the fields the document contains and the syntax that a computer system can use to encode data.  In technical terms, an EDI document is a file with data formatted using a combination of alphanumeric codes, special characters, and line breaks, sometimes using a specific XML format.  In order to use EDI, your system needs to be able to receive and send files and have the required logic to parse the information using the EDI standard that you are targeting.

How does EDI relate to larger information systems?

Businesses often use multiple software systems that store, receive and transmit business data.  Software engineers that design such information systems may use general software development patterns to allow these systems to communicate, for example, by creating an Application Programming Interface or API based on standards such as REST or SOAP.  Under these standards, each system defines its own ad hoc document definitions. EDI, on other hand, provides a common set of document definitions that all businesses can use to send and receive information.

Even though EDI standards provide a standard language for electronic communication, we find that translating from the EDI format to a custom data model is often required. In the example of a warehouse, a shipping manifest in EDI format gives us information such as a related purchase order number, carrier details, and descriptions of the items being shipped. In order to store this information, we should normalize this data in our database, and we may need to associate these items to additional data in the warehouse’s internal data model. This step requires us to extract the data from the EDI document and then map it to the warehouse system’s data model.

Conversely, if we want to send EDI documents to other business partners, we need to be able to transform our internal system’s data into an EDI document.  In order to do this, we need to extend our architecture with a new component that is responsible for receiving EDI documents and translating them from the EDI standard into the data model that we use inside our system.

Integrating EDI with Stedi

At FullStack Labs, we try to recommend solutions that will make custom development faster and less expensive while still delivering high-quality business software. When starting a project that requires custom EDI integration, one choice is to write a completely custom solution. This would be very costly and add considerable time to the development effort.

Alternatively, we could use open source EDI libraries as a starting point for our EDI component.  These may save some initial development effort, but they have limited support options which mean higher ongoing maintenance costs, uncertainty, and potential business disruption in the long term.  

Stedi is a startup that has created a product that supports developers building custom EDI integrations. Currently, Stedi has two offerings: a free EDI reference and a paid EDI integration platform. The paid EDI product from Stedi strikes a balance between these two choices by providing pre-built EDI integration tooling that shortens development time and cost while offering a product maintained by EDI experts that will support your business in the long term.   

The EDI Reference

The EDI reference gives detailed descriptions of X12 EDI documents. The reference covers multiple X12 releases. For each release, it breaks down transaction sets, segments, and elements.  A transaction set is a high-level document, ranging from numbers 100 to 999. Each transaction set is made up of segments, and segments contain elements.

Looking at their documentation, let’s take a look at the information it provides regarding an example EDI purchase order shown below. We’ll unpack the two lines boxed in red to get an understanding of how an EDI file works. I’ll add links below to the documentation, but Stedi may still require you to create a free account in order to view it.

An example EDI purchase order document

We can see that the transaction set number for a purchase order is 850. Drilling down, we find that the first segment, ST, is the Transaction Set Header, which contains the first element, the Transaction Set Identifier Code, which lists all the transaction sets possible in the X12 specification (in this case, 850). This element is the identifying element that tells us what transaction set, or document type, we’re reading. Going further, the next segment is BEG, or Beginning Segment for Purchase Order, whose first element is Transaction Set Purpose Code, which lists codes like 00, 01, and 02, which map to Original, Cancellation, and Add, respectively.  In this case, we have “00” so this is the original purchase order. The rest of the segment lists the purchase order type (in the below example, SA, or Stands Alone), the PO number (A99999-01), and the PO Date (1997-02-14).

This brief overview of the documentation gives us an idea of the cryptic nature of EDI, but Stedi’s documentation is very well done and with some systematic study can allow humans to read an EDI document. Stedi even provides a very convenient EDI Inspector that allows you to break down the values in an X12 EDI document.

Stedi’s EDI Integration Platform

At this point, we have a better understanding of the value an existing EDI library provides.  Stedi’s API consists of several components that help developers quickly build a custom EDI integration.

The first component is called EDI Core.  EDI core is responsible for translating an EDI document into something that Stedi has cleverly calle JEDI (JSON EDI).  Taking the above example document, EDI Core will translate it to:

An example of an EDI document transformed to JEDI

We can see that the values that were written on the individual lines above have been parsed into JSON objects.  To a developer, this is slightly more readable, but it still contains a lot of EDI codes that are not human-friendly.

To assist with mapping the JEDI to more human-readable JSON, Stedi offers a mapping feature.  Currently, it is only code-based, but a visual mapping UI will be available in their online console soon.  

The mapping feature is a javascript function that accepts JEDI as an argument and returns a javascript object, allowing the developer to use functions such as map to parse JEDI arrays into simpler custom JSON shapes which can be consumed by a webhook, enabling real-time updates of EDI data as it arrives.  

One limitation is that there currently is no way to look up EDI element codes, although Stedi responded that this feature is on their roadmap for possible future development. Stedi’s documentation does provide values for EDI codes, so it would be up to the developer to create lookup tables in their own code with human-friendly values for the document types they need to support. 

In addition to the EDI Core product, Stedi offers several other products that help you quickly stand up EDI infrastructure, giving you a toolbox for quickly creating test and production EDI environments. These products are still in developer preview, although Stedi has reported that stable versions will become available soon. For developers familiar with cloud infrastructure and infrastructure as code (IaC), the patterns Stedi has used should seem familiar, as they have created a collection of cloud-based services that developers can provision to support EDI processing. You can find out more about these products by consulting their documentation.

Depending on what industry you work in, it’s possible that as a developer you may not have encountered EDI before. At this point, I hope that you are more familiar with the EDI format and have a better idea of how one solution, Stedi, can help you build a custom EDI integration.

Jeremy Garner
Written by
Jeremy Garner
Jeremy Garner

I ventured into software development when I was working as a language teacher and I had an idea for a teaching app I wanted.  I couldn’t talk anyone into building it for me so I started teaching myself programming. The best feeling is when you’ve made something that makes someone’s job or life a little easier or less frustrating. Plus you get paid to solve puzzles. Of all the technologies I use, I particularly love the history of JavaScript/ECMAScript. I think it’s allegorical: a little language that was written in a few weeks based on a few of the author’s favorite ideas and has grown into the most popular programming language in the world. To me, when asking about success, it’s a lesson in the tension between preparation and luck, idealism and pragmatism, complexity and simplicity, and taking a risk on innovation vs. marketing to established trends. Before Covid, I enjoyed music and traveling, but during the pandemic, I've played more chess, embarked on a camper van project, and gardened.

People having a meeting on a glass room.
Join Our Team
We are looking for developers committed to writing the best code and deploying flawless apps in a small team setting.
view careers
Desktop screens shown as slices from a top angle.
Case Studies
It's not only about results, it's also about how we helped our clients get there and achieve their goals.
view case studies
Phone with an app screen on it.
Our Playbook
Our step-by-step process for designing, developing, and maintaining exceptional custom software solutions.
VIEW OUR playbook
FullStack Labs Icon

Let's Talk!

We’d love to learn more about your project.
Engagements start at $75,000.

company name
name
email
phone
Type of project
How did you hear about us?
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.