📅 Fireside Chat: Future of Analytics on the Modern Data Stack with Hex, Transform, and RudderStack

Register Now
By Rudderstack Team

How to load data from Recurly to Google BigQuery

This post helps you with loading your data from Recurly to BigQuery. If you are looking to get analytics-ready data without the manual hassle, you can integrate Recurly to BigQuery with Rudderstack, so you can focus on what matters, getting value out of your business data.

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, merchants can start immediately subscribing to their customers with minimal effort and without requiring significant technical skills.
  • js. A JavaScript library that can be used to integrate the functionality of Recurly in your product securely.
  • API. A Web API that exposes the full functionality of Recurly through its interface for integrating with it programmatically.

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:

  • PHP (official)
  • Ruby (official)
  • Python (official)
  • .NET (official)

Recurly iOS SDK in official CocoaDocs organization

  • Android (official)
  • Java (unofficial)
  • Go (unofficial)
  • Node.js (unofficial)

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 favorite 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.com/v2/accounts

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.

The 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 to 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.

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 maximize recurring revenues. It is easy to set up. A company can be up and running with Recurly in days instead of months, compared to building your recurring 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 set up and configure trials for your product. It is also possible to include setup fees if your product requires these.
  • 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 interact with customers, data that you would like to export and analyze 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.

Prepare your data to be sent from Recurly to Google BigQuery

Before you load your data into BigQuery, you should make sure that it is presented in a format supported by it. For example, if the API you pull data from returns XML, you have to first transform it into a serialization that BigQuery understands. Currently, two data formats are supported:

You also need to make sure that the data types you are using are the ones supported by BigQuery, which are the following:

  • STRING
  • INTEGER
  • FLOAT
  • BOOLEAN
  • RECORD
  • TIMESTAMP

For more information, please check the Preparing Data for BigQuery page on the documentation.

About Google BigQuery

BigQuery is the data warehousing solution of Google. It’s part of the Google Cloud Platform, and it also speaks SQL as Redshift does. Queries are executed against append-only tables using the processing power of Google’s infrastructure. It is also fully managed and is offered as a service over the cloud. You can interact with it through its web UI, using a command-line tool while a variety of client libraries exist so you can interact with it through your application.

Load Data from Recurly to Google BigQuery

If you want to load data from Recurly to Google BigQuery, you have to use one of the following supported data sources:

  1. Google Cloud Storage
  2. Sent data directly to BigQuery with a POST request
  3. Google Cloud Datastore Backup
  4. Streaming insert
  5. App Engine log files
  6. Cloud Storage logs

From the above list of sources, 5 and 6 are not applicable in our case.
For Google Cloud Storage, you first have to load your data into it. There are a few options on how to do this. For example, you can use the console directly as described here, and do not forget to follow the best practices. Another option is to post your data through the JSON API. As we see again, APIs play an important role in both the extraction and the loading of data into our data warehouse. It’s the simplest case, it’s just a matter of one HTTP POST request using a tool like CURL or Postman. It should look like the following example.

POST /upload/storage/v1/b/myBucket/o?uploadType=media&name=myObject HTTP/1.1
Host: www.googleapis.com
Content-Type: application/text
Content-Length: number_of_bytes_in_file
Authorization: Bearer your_auth_token
your Recurly data

and if everything went ok, you should get something like the following as a response from the server: