YANRC (Yet Another Node Recurly Client)


100.2.74 years ago6 years agoMinified + gzip package size for node-recurly-client in KB


The Recurly Client

There was a library already. But I didn't quite like it. So I created my own library, with blackjack and generics.

The code covers most methods described in the Recurly Developer Hub.


You can configure xml2js parser, that lives under the hood. Like this:

new Recurly({
  /* API key, subdomain */
}, {
  /* xml2js conf! */

The library doesn't check weird callback length whatsoever (as neighboring does). Who need those things?



npm install --save node-recurly-client


var Recurly = require('node-recurly-client');
var recurly = new Recurly({
  apiKey: 'api-key-goes-here',
  subdomain: 'subdomain-goes-there'

  account_code: '0xdeadbeef',
  email: ''
}, function (err, response) {/* processing etc. */});

How does this thing work?

You may notice, that library doesn't have any methods explicitly defined, that call Recurly resource. Isn't it lovely?

Roughly saying, the library does the following:

  1. Get the request library.
  2. Set the default headers.
  3. Magically create methods by provided JSON files.

The JSON files live in the library under lib/schemas path. Usually, you don't need to worry about them.

All request parameters subordinate to the following logic:

  1. URI parameters go as separate parameters.
  2. Body object if any goes after all URI parameters.
  3. The callback is obligatory and is the last parameter.

Let's take as an example update subscription call. It wants one parameter in URI and a body. The call would look like this:

recurly.subscription.update('uuid-string', {/* body */}, callback);

How would another random call would look like, if there would be multiple URI parameters? Easy!, uriParamString2, bodyObj, callback);

If there are no modifiers in URI, those parameters have to be omitted. If there is no body, body parameter has to be omitted.



recurly.accounts.create(body, cb);
recurly.accounts.lookup(accountCode, body, cb);
recurly.accounts.update(accountCode, body, cb);
recurly.accounts.close(accountCode, cb);
recurly.accounts.reopen(accountCode, body, cb);
recurly.accounts.balance(accountCode, cb);
recurly.accounts.notes(accountCode, cb);

Account Acquisition

recurly.accountAcquisition.create(accountCode, body, cb);
recurly.accountAcquisition.lookup(accountCode, cb);
recurly.accountAcquisition.update(accountCode, body, cb);
recurly.accountAcquisition.clear(accountCode, cb);


recurly.adjustments.list(accountCode, cb);
recurly.adjustments.create(accountCode, body, cb);
recurly.adjustments.lookup(uuid, cb);
recurly.adjustments.delete(uuid, cb);

Billing info

recurly.billingInfo.create(accountCode, body, cb);
recurly.billingInfo.lookup(accountCode, cb);
recurly.billingInfo.update(accountCode, body, cb);
recurly.billingInfo.clear(accountCode, cb);

Coupons;, cb);, cb);, body, cb);, cb);, body, cb);, body, cb);, cb);

Coupon redemptions

recurly.couponRedemptions.account(accountCode, cb);, redemptionUuid, cb);
recurly.couponRedemptions.invoice(invoiceNumber, cb);
recurly.couponRedemptions.subscription(uuid, cb);
recurly.couponRedemptions.redeem(couponCode, cb);
recurly.couponRedemptions.remove(accountCode, uuid, cb);

Gift cards

recurly.giftCards.preview(body, cb);
recurly.giftCards.create(body, cb);
recurly.giftCards.lookup(id, cb);
recurly.giftCards.redeem(redemptionCode, body, cb);
recurly.giftCards.previewSubscription(body, cb);
recurly.giftCards.createSubscription(body, cb);


recurly.invoices.listAccount(accountCode, cb);
recurly.invoices.preview(accountCode, body, cb);, body, cb);
recurly.invoices.lookup(invoiceNumber, cb);
recurly.invoices.markAsPaid(invoiceNumber, cb);
recurly.invoices.markAsFailed(invoiceNumber, cb);
recurly.invoices.refundLineItem(invoiceNumber, body, cb);
recurly.invoices.refundOpenAmount(invoiceNumber, body, cb);
recurly.invoices.offlinePayment(invoiceNumber, body, cb);


recurly.plans.create(body, cb);
recurly.plans.lookup(planCode, cb);
recurly.plans.update(planCode, cb);
recurly.plans.delete(planCode, cb);

Plan add-ons

recurly.planAddOns.list(planCode, cb);
recurly.planAddOns.create(planCode, body, cb);
recurly.planAddOns.lookup(planCode, addOnCode, cb);
recurly.planAddOns.update(planCode, addOnCode, body, cb);
recurly.planAddOns.delete(planCode, addOnCode, cb);

Measured units

recurly.measuredUnits.create(body, cb);
recurly.measuredUnits.lookup(measuredUnitId, cb);
recurly.measuredUnits.update(measuredUnitId, body, cb);
recurly.measuredUnits.delete(measuredUnitId, cb);


recurly.subscriptions.list(accountCode, cb);
recurly.subscriptions.preview(body, cb);
recurly.subscriptions.create(body, cb);
recurly.subscriptions.lookup(uuid, cb);
recurly.subscriptions.previewChange(uuid, body, cb);
recurly.subscriptions.update(uuid, body, cb);
recurly.subscriptions.updateNotes(uuid, body, cb);
recurly.subscriptions.cancel(uuid, cb);
recurly.subscriptions.reactivate(uuid, cb);
recurly.subscriptions.terminate(uuid, refundType, charge, cb);
recurly.subscriptions.postpone(uuid, nextRenewalDate, bulk, cb);

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from