Get Subscriber Info from Spreedly

To retrieve subscriber information, you just send an HTTP GET request to a url formatted like so:

https://spreedly.com/api/[api_version]/[site_name]/subscribers/[customer_id].xml

where [api_version] is currently “v4” (more about API versions). The [site_name] is the name you specified to identify your site when you created it (can be changed in Site Details) and [customer_id] is the id you use for the subscriber.

[ ~ ] $ curl https://spreedly.com/api/v4/meresheep/subscribers/7388.xml
HTTP Basic: Access denied.

Notice that access was denied. We're actually returning a 401 status code (Unauthorized). You can see the status code returned in curl using the -v command line switch. Now let's try with our username and a password of X:

[ ~ ] $ curl -u duff:X https://spreedly.com/api/v4/meresheep/subscribers/7388.xml
HTTP Basic: Access denied.

Access denied again. In order to access the api, you need to obtain the API authentication token for your site, which you can see in your site settings.

When you use this token, simple XML is returned. Notice that a password is not necessary here. I specified an ‘X' because it's often easier to do that since many clients require a password. Spreedly ignores this password for API calls.

[ ~ ] $ curl -u cbb8f088775cf209035729c0eb69b9f340a3b047:X https://spreedly.com/api/v4/meresheep/subscribers/7388.xml

Here is the response:

  <?xml version="1.0" encoding="UTF-8"?>
  <subscriber>
    <active-until type="datetime" nil="true"></active-until>
    <billing-first-name nil="true"></billing-first-name>
    <billing-last-name nil="true"></billing-last-name>
    <created-at type="datetime">2010-07-07T21:20:39Z</created-at>
    <customer-id>7388</customer-id>
    <eligible-for-free-trial type="boolean">true</eligible-for-free-trial>
    <email nil="true"></email>
    <grace-until type="datetime" nil="true"></grace-until>
    <lifetime-subscription type="boolean">false</lifetime-subscription>
    <on-gift type="boolean" nil="true"></on-gift>
    <on-metered type="boolean">false</on-metered>
    <on-trial type="boolean">false</on-trial>
    <ready-to-renew type="boolean">false</ready-to-renew>
    <ready-to-renew-since type="datetime" nil="true"></ready-to-renew-since>
    <recurring type="boolean" nil="true"></recurring>
    <screen-name></screen-name>
    <store-credit type="decimal">0.0</store-credit>
    <store-credit-currency-code>USD</store-credit-currency-code>
    <token>2b83780b907248eb1e305af11d2c92f7b1f7ec76</token>
    <updated-at type="datetime">2010-07-07T21:20:39Z</updated-at>
    <card-expires-before-next-auto-renew type="boolean">false</card-expires-before-next-auto-renew>
    <subscription-plan-name></subscription-plan-name>
    <active type="boolean">false</active>
    <in-grace-period type="boolean"></in-grace-period>
    <feature-level type="string"></feature-level>
    <invoices type="array"/>
  </subscriber>

This was a successful call to the API. The status code returned is 200 (OK).

Let's say you request information about a non-existent subscriber. Spreedly returns a status code of 404 (Not Found) in this case.

Next Step →

Return to the Integration Guide ↑

Extra Credit

You can also retrieve information about all of the subscribers with an HTTP GET like this:

[ ~ ] $ curl -u cbb8f088775cf209035729c0eb69b9f340a33042:X https://spreedly.com/api/v4/meresheep/subscribers.xml
Olark Livehelp