How to load data from Recurly to SQL Data Warehouse

Blendo Team

How may I load data from Recurly to SQL Data Warehouse for further analysis? The purpose of this post is to help you define a process or pipeline, for getting your subscription related data from Recurly and load it into SQL Data Warehouse for further analysis. We will see how to access and extract your data from Recurly through its API and how to load it into SQL Data Warehouse. This process requires from you to write the code to get the data and make sure that this process will run every time new data are generated. Alternatively you can use products like Blendo that can handle this kind of problems automatically for you.

About Recurly

Recurly is a subscription billing management service. It currently provides enterprise-class subscription management for thousands of businesses worldwide. It offers a trusted, flexible subscription management solutions that help companies to maximise recurring revenues. It is easy to setup, a company can be up and running with Recurly in days instead of months, compared to building your own recurrent subscription service for your product. Regarding subscriptions it offers the following:

  • Plan management. You can create as many plans as you want, define billing cycles and manage upgrades and downgrades.
  • Multi-subscription support. Your customers can have multiple subscriptions running simultaneously.
  • Trials & Setup fees. You can easily setup and configure trials for your product. It is also possible to include setup fees if these are required by your product.
  • Virtual terminal. Recurly provides an easy and intuitive interface to set up subscriptions or process one-time payments over the phone.
  • Add-ons. Add-Ons provide a great deal of versatility for your business. By presenting optional Add-Ons, your subscribers select the plan that is perfectly tailored to suit their needs.

A subscription system like Recurly generates a lot of valuable data related to how your product and company interacts with customers, data that you would like to be able to export and analyse in order to drive your business and your product development. Fortunately, Recurly exposes a rich ecosystem of tools and APIs that you can use to get the most out of their service and have full control over both your data and your integration with their platform.

About Microsoft Azure SQL Data Warehouse

SQL Data Warehouse is the data warehousing solution that you can use if you are a user of Microsoft Azure. It’s an elastic data warehousing as a service solution, emphasising it’s enterprise focus. It also speaks SQL like the previous two solutions and it supports querying both relational and non-relational data.  It offers a number of enterprise-class features like support for hybrid cloud installations and strong security. It’s probably the less mature solution compared to the two others though, it’s still in “Preview” mode although accessible to existing Azure subscribers.

Extract your data from Recurly

The Recurly API allows applications to interact directly with its platform. In general, Recurly offers the following ways of integrating with their services:

  • Hosted Payment Pages. With this product it is possible for merchants to start immediately subscribing their customers with minimal effort and without requiring significant technical skills.
  • js. A JavaScript library that can be used to securely integrate the functionality of Recurly in your product.
  • API. A Web API that exposes the full functionality of Recurly through its interface for integrating with it programatically.

From the above three methods, we are interested in the last one as it is the only way that we can use to pull data from the Recurly platform. There’s also a plethora of SDKs so you can interact with the API from your language or framework of choice:

The Recurly API is a RESTful web service. As a RESTful API, interacting with it can also be achieved by using tools like CURL or Postman or Apirise or by using http clients for your favourite language or framework, instead of one of the previously mentioned SDKs. A few suggestions:

Recurly API Authentication

Recurly is using HTTP Basic Authentication using your API Key for credentials. All data are transferred over a secure SSL channel. Below an example using Curl that demonstrates how authentications works for Recurly:

curl -H 'Accept: application/xml' \
     -H 'X-Api-Version: 2.1' \
     -H 'Content-Type: application/xml; charset=utf-8' \
     -u [API Key]: https://[subdomain]


Recurly supports the use of multiple Private API keys, which can be used to integrate third party services using unique, controlled credentials. With the following limitations:

  • Core & grandfathered Recurly plans are granted 5 private API keys.
  • Professional plan grants 10 API keys.

Rate Limits

By default, new Recurly sites have the following API rate limits:

  • Sandbox sites: 400 requests/min. All requests count towards the rate limit.
  • Production sites: 1,000 requests/min. Only GET requests count towards the rate limit.

Once your site moves into production mode, Recurly will only rate limit GET requests. New subscriptions, account modifications, and other requests using POST, PUT, or DELETE methods will not count against your rate limit.

The rate limit is calculated over a sliding 5 minute window. This means a production site could make 4,000 requests within one minute and not hit the rate limit so long as the site made less than 1,000 requests during the prior 4 minutes.

If an API request exceeds the rate limit, the API returns a 429 status code indicating Too Many Requests.

Load Data from Recurly to SQL Data Warehouse

SQL Data Warehouse support numerous options for loading data, such us:

  • PolyBase
  • Azure Data Factory
  • BCP command-line utility
  • SQL Server integration services

As we are interested in loading data from online services by using their exposed HTTP APIs, we are not going to consider the usage of BCP command-line utility or SQL server integration in this guide. We’ll consider the case of loading our data as Azure storage Blobs and then use PolyBase to load the data into SQL Data Wareho use.

Accessing these services happens through HTTP APIs, as we see again APIs play an important role in both the extraction but also the loading of data into our data warehouse. You can access these APIs by using a tool like CURL, Postman or Apirise. Or use the libraries provided by Microsoft for your favourite language. Before you actually upload any data you have to create a container which is something similar as a concept to the Amazon AWS Bucket, creating a container is a straight forward operation and you can do it by following the instructions found on the Blog storage documentation from Microsoft. As an example, the following code can create a container in Node.js.

blobSvc.createContainerIfNotExists('mycontainer', function(error, result, response){
    // Container exists and allows
    // anonymous read access to blob
    // content and metadata within this container

After the creation of the container you can start uploading data to it by using again the given SDK of your choice in a similar fashion:

blobSvc.createBlockBlobFromLocalFile('mycontainer', 'myblob', 'test.txt', function(error, result, response){
    // file uploaded

When you are done putting your data into Azure Blobs you are ready to load it into SQL Data Warehouse using PolyBase. To do that you should follow the directions in the Load with PolyBase documentation. In a summary the required steps to do it, are the following:

  • create a database master key
  • create a database scoped credentials
  • create an external file format
  • create an external data source

PolyBase’s ability to transparently parallelize loads from Azure Blob Storage will make it the fastest tool for loading data. After configuring PolyBase, you can load data directly into your SQL Data Warehouse by simply creating an external table that points to your data in storage and then mapping that data to a new table within SQL Data Warehouse.

Of course you will need to establish a recurrent process that will extract any newly created data from your service, load them in the form of Azure Blobs and initiate the PolyBase process for importing the data again into SQL Data Warehouse. One way of doing this is by using the Azure Data Factory service. In case you would like to follow this path you can read some good documentation on how to move data to and from Azure SQL Warehouse using Azure Data Factory.


The best way to load data from Reculry to SQL Data Warehouse and possible alternatives

So far we just scraped the surface of what can be done with Microsoft Azure SQL Data Warehouse and how to load data into it. The way to proceed relies heavily on the data you want to load, from which service they are coming from and the requirements of your use case. Things can get even more complicated if you want to integrate data coming from different sources. A possible alternative, instead of writing, hosting and maintaining a flexible data infrastructure, is to use a product like Blendo that can handle this kind of problems automatically for you.

 Blendo integrates with multiple sources or services like databases, CRM, email campaigns, analytics and more.  Quickly and safely move all your data from Recurly into SQL Data Warehouse and start generating insights from your data.