Stedi
Blog February 9, 2022

Converter: one step closer to any-to-any data integration

David Kanter

Businesses of all sizes exchange commercial transactions like purchase orders, ship notices, healthcare claims, and invoices in a wide variety of file formats.

For developers who need to translate EDI, Stedi offers EDI Core – and for transforming JSON payloads, Stedi offers Mappings. Developers looking to build scalable B2B integrations also need to handle XML and CSV.

Introducing Converter

Converter is an API that offers developers a convenient way to convert CSV and XML files into JSON. Converter supports the following operations:

  • CSV to JSON
  • JSON to CSV
  • XML to JSON
  • JSON to XML (Coming soon!)

The API features many customization options that make transforming files less error-prone and easier to manipulate programmatically.

Seamless integration with your EDI workflow

Stedi’s APIs can be chained together in any sequence, depending on the required input and desired output shape. The launch of Converter makes the following payload transformations possible:

InputFlow of transformationsOutput
EDIEDI Core → Mappings → ConverterCSV/XML
JSONMappings → ConverterCSV/XML
JSONConverterCSV/XML
CSV/XMLConverterJSON
CSV/XMLConverter → MappingsJEDI
CSV/XMLConverter → Mappings → ConverterCSV/XML
CSV/XMLConverter → Mappings → EDI CoreEDI

Converter adds a layer of convenience not offered by traditional EDI systems or open-source libraries. With uptime guarantees and a security-first approach, the API provides a reliable solution that can easily be used in conjunction with other Stedi products.

Using Converter

Converter API calls are initiated from your infrastructure through an HTTP client; they require a payload and certain target format options.

As an example, let’s assume you received an invoice in a CSV format, which you need to send to the NetSuite REST API. You can convert the CSV file to JSON by posting it to the https://converter.stedi.com/2021-10-01/csv_to_json endpoint.

In the example below, the Converter API uses the headers in the CSV as keys in the JSON. The result is a list with an object for each row, where the object has a field for each column. So, if you have a CSV like this…

type,invoiceNumber,poNumber,amt
invoice,INV20023,30278099,100.50
invoice,INV20024,30288899,50.99

…the resulting JSON will look like this:

{
   "output": [
       {
           "type": "invoice",
           "invoiceNumber": "INV20023",
           "poNumber": 30278099,
           "amt": 100.5
       },
       {
           "type": "invoice",
           "invoiceNumber": "INV20024",
           "poNumber": 30288899,
           "amt": 50.99
       }
   ]
}

Alternatively, you can set the has_header option to false. This will produce a two-dimensional list, providing you with a more condensed output, convenient for working with programatically.

{
   "output": [
       ["type","invoiceNumber","poNumber","amt"],
       ["invoice","INV20023",30278099,100.5],
       ["invoice","INV20024",30288899,50.99]
   ]
}

Knowing that CSV files are often handled by a person, we know that human errors can easily arise. As a result, we’ve taken steps to make the Convert API more robust by offering options such as:

  • trim which removes whitespace at the beginning and end of each value, and
  • convert_types which turns values into numbers and booleans where possible.

To highlight these configuration options, suppose you have a CSV that looks as follows:

Type, invoiceNumber,poNumber,amt
invoice,INV20023, 30278099,100.50
invoice,INV20024,30288899, 50.99

By default, with both options set to false, the result would look like this:

{
   "output": [
       {
           "type": "invoice",
           " invoiceNumber": "INV20023",
           "poNumber": " 30278099",
           "amt": "100.50"
       },
       {
           "type": "invoice",
           " invoiceNumber": "INV20024",
           "poNumber": "30288899",
           "amt": " 50.99"
       }
   ]
}

When you set both options to true, you’ll get the following output:

{
   "output": [
       {
           "type": "invoice",
           "invoiceNumber": "INV20023",
           "poNumber": 30278099,
           "amt": 100.5
       },
       {
           "type": "invoice",
           "invoiceNumber": "INV20024",
           "poNumber": 30288899,
           "amt": 50.99
       }
   ]
}

And to help with troubleshooting problems, every error contains a machine-readable code and a human-readable message with guidance on how to fix the issue.

Converter is now Generally Available

Converter allows developers to convert various formats like CSV and XML to JSON, providing a hassle-free way to manage these conversions. Converter has a transparent, pay-per-use pricing model with a generous free tier. There are no minimum fees, monthly commitments, or upfront costs to use this product.

If you’re ready to start building, check out the example TypeScript project in our public Starter-Kit repo or you can use our Postman collection to start hitting the API today.

Get started by creating an API Key

Featured
Converter
Convert between CSV, XML, and JSON

Converter is a convenient collection of APIs that supports JSON to CSV, CSV to JSON, and XML to JSON.

Try Converter Learn more
Share
Previous
EDI Core: the foundation of any reliable EDI system
Subscribe

Get blog posts delivered to your inbox.

Products
EDI CoreMappingsConverterPricing
Follow
  1. Twitter
  2. GitHub
Backed by
AdditionBloomberg BetaFirst RoundStripeUSV
System StatusCustomer AgreementService TermsPrivacy Notice

Stedi is a registered trademark of Stedi, Inc. All names, logos, and brands of third parties listed on our site are trademarks of their respective owners (including “X12”, which is a trademark of X12 Incorporated). Stedi, Inc. and its products and services are not endorsed by, sponsored by, or affiliated with these third parties. Our use of these names, logos, and brands is for identification purposes only, and does not imply any such endorsement, sponsorship, or affiliation.