Learn how Alloy Unified API works under the hood.


On the surface, it might seem that Alloy Unified API is just a simple middleware to map data from various sources to a common format. This is only part of the story. In this tutorial, we'll take a look at how Unified API works under the hood and the technology that powers it.

Unified API Infrastructure

So far, we've taken a look at how to connect to Alloy Unified API and implement the Alloy Modal in your frontend. Now, let's take a look at what happens behind the scenes when an end user connects. In the diagram below, we've broken down how Unified API works at a high level. When your end user first connects their app to Unified API, Alloy fires off a historical sync to grab as much data as possible – by default, we query 2 years of historical data.

As soon as his historical sync job is triggered, we begin a series of actions described below.

Let's take a look at the various components here:

  • Third Party Apps (3PAs): On the very left hand side, you'll notice various apps (Shopify, WooCommerce, etc). These apps return data in the raw format from the Third Party App. Alloy Unified API aggregates data from each of these 3PAs. When your end user connects to Unified API, Alloy subscribes to all relevant webhooks the 3PA provides and schedules a recurring 12 hour polling job. This job checks for any dropped events (in the event that webhooks become unreliable) and in the case of apps without webhooks, ensures Alloy Unified API is always up to date.
  • Standardize: Moving slightly to the right, you'll notice that Alloy Unified API standardizes the data. Here, Unified API takes the raw data coming from the 3PA and maps it to our common models.
  • Unified API Cache: Once the data is standardized, we then store this data in the Alloy Unified API Cache. From here, you can make API requests to grab the data you want. Each time an event (i.e. a record is created, updated, or deleted in the 3PA, the cache is updated accordingly). Alloy's Unified API Cache acts as a mirror copy of the data stored in the 3PA.
  • API Request: Moving further to the right, this is when you come in. When an ISV makes an API call to Alloy Unified API, you hit the Alloy Cache via our public API endpoints. These endpoints return data in a consistent, standardized format each time.

Webhook Subscriptions

As mentioned above, behind the scenes, Alloy Unified API subscribes to all relevant real time webhooks that a 3PA may offer. Take Shopify as an example. Shopify offers real time events every time an order is created, customer updated, etc. Alloy Unified API subscribes to all relevant events by default. Unfortunately, some 3PAs don't offer webhooks. Take NetSuite, a popular ERP, as an example. To get around this, Alloy regularly polls for changed data – created, updated, and deleted records – and updates the cache accordingly.

You can subscribe to these events in real time using the Webhook Forwarding feature.

Wrapping Up

In this article, we took a look at how Alloy's Unified API architecture works behind the scenes and explored how Unified API syncs, standardizes, and stores data from various formats into a consistent common model.