customers/get

Stephen Rhyne's Avatar

Stephen Rhyne

16 Mar, 2011 10:36 PM

I'm trying to build a nice CG IOS app with Sencha touch & Phonegap! I want to scratch my own itch and help make CG even better. But, I'm running into a problem with the API. customers/get, when I call it on my own CG account, takes like 43 seconds to finish and is 4.6mb in size. Perhaps I'm missing something but is there a way to get a lean version of an account customer list? You know without every single invoice and subscription elements that repeat themselves over and over?

If not, I can still use customers/get as like a client side model with localStorage and have users just periodically update the store. But, again, the time it takes to grab the data when it's not in your query cache is 43 seconds? I'm thinking if 43 seconds is how long it takes on my account with 180 customers how long does it take on someone with 1000 customers?

In your defense I realize that your API get's interacted with mostly by applications that already have a list of their clients so they can iterate over their clients and make single calls with code/.

Question two. If you don't have a way to do this currently, how soon do you think you could optimize customers/get or add a lean version sort of like your updates separated by subscription or client info?

Thanks!

-Stephen Rhyne @srhyne

  1. Support Staff 1 Posted by Marc Guyer on 17 Mar, 2011 02:54 PM

    Marc Guyer's Avatar

    Hi Stephen -- That issue has been on our list for a while. We haven't yet come up with a good solution that maintains backward compatibility. In hindsight, customers/get should only return the current subscription and current invoice. Unfortunately it returns a full history for each customer. I'm pretty sure we will need to break BC at some point because the current behavior is unusable. That will take an orchestrated effort including communication with existing users and a time delay.

    In the short term, we might consider creating a new secret call just for you...

  2. 2 Posted by Stephen Rhyne on 19 Mar, 2011 06:49 PM

    Stephen Rhyne's Avatar

    Hi Marc,

    Thanks for getting back to me. Perhaps you could setup your /customers/ controller like you do your /edit/ controller. You have edit, edit-customer, and edit-subscription. So you could have perhaps customers/get/ to return all info like you are now and customers/get-customer/ for just customer info?

    I'd be super happy to get this resource as I really want to build this app.

    Thanks Marc. Be well!

    -Stephen Rhyne @srhyne

  3. Support Staff 3 Posted by Marc Guyer on 23 Mar, 2011 01:10 PM

    Marc Guyer's Avatar

    Hi Stephen -- We're working on something for you. Stay tuned!

  4. Support Staff 4 Posted by Marc Guyer on 23 Mar, 2011 04:20 PM

    Marc Guyer's Avatar

    Hi again -- Our devs were able to get this out quicker than I thought...

    There is a new api method: /customers/list. The available parameters are basically the same as customers/get but there is no orderBy.

    You can try it out now but it is subject to change. Consider it in beta. Some rough stats:

    Sample set of 500 customers with up to 5 months of history.

    • customers/get time: 1:15
    • customers/list time: 0:01
    • customers/get size: 6237k
    • customers/list size: 617k

    The list method is basically the same as the get method on the surface. The xml format is very similar. The major difference is less information and no history. In other words, only current subscription and current invoice is returned. No tracked item information, current charges, etc. What's included is essentially basic information about the customer, the current subscription and the current invoice.

    Please let us know if you have questions or suggestions.

  5. 5 Posted by Stephen Rhyne on 23 Mar, 2011 09:40 PM

    Stephen Rhyne's Avatar

    Marc,

    Thank you so much for this update! Very impressed with how quickly you were able to get this done. I'm looking forward to using it!

    -Stephen

  6. 6 Posted by Stephen Rhyne on 03 Apr, 2011 06:14 PM

    Stephen Rhyne's Avatar

    I'm getting an XML error on customers/list

    `error on line 32 at column 19: Opening and ending tag mismatch:
    createdDatetime line 0 and subscription`

    Just an FYI. Thanks for the awesome API call. Waaaay faster.

  7. Support Staff 7 Posted by Marc Guyer on 05 Apr, 2011 01:44 PM

    Marc Guyer's Avatar

    Thanks for the bug report. We'll have a fix deployed today.

  8. 8 Posted by David on 10 Apr, 2011 02:19 AM

    David's Avatar

    Marc.

    I'm using the customers/list api now also... its much faster... Thanks

    Can you add current information for the customers cc_Type; cc_LastFour; cc_ExpirationDate; cc_zip

    This would help me provide current payment info to my customers with this new api.

  9. 9 Posted by David on 10 Apr, 2011 04:16 AM

    David's Avatar

    Never mind my last post... I think I figured it out...

  10. 10 Posted by Stephen Rhyne on 05 Apr, 2012 11:44 PM

    Stephen Rhyne's Avatar

    I would love to see transactionDate start/end limiters on on customers/get1. I've been using the call but it's quite slow. Probably because the call is like 11mb! haha. I think that if I could limit the amount of transactions to just a year or month that would really cut down the weight.

    Thanks!

  11. Support Staff 11 Posted by Marc Guyer on 06 Apr, 2012 03:10 PM

    Marc Guyer's Avatar

    We're going to need to make some changes to the customers/get call because it is so inefficient. We'll probably add some limitations like a max number returned with paging. Also, we'll likely reduce the amount of history for individual accounts. This is all theoretical.

    I'd like to understand your use-case so I can better help you with this particular situation. What is it you're trying to accomplish?

  12. 12 Posted by Stephen Rhyne on 06 Apr, 2012 04:13 PM

    Stephen Rhyne's Avatar

    Well, last week I had to create a revenue report that listed each one of my WA state customer's total revenue for 2011. So here's how I had to do it.

    I first started by trying to do it all cross-domain from file:// in Safari then just use jQuery as an element selector on the customers/get xml. However, that crashed Safari due to the 11mb I got back ;)

    Plan B

    • cURL'd customers/get into a local customers.xml file
    • Wrote a PHP class to that filtered the data for me using simpleXML

    There's so much awesome data in there that could be summarized. Considering creating a reporting app using slim.php connected to the customers.xml file.

  13. 13 Posted by Alex on 02 Jun, 2012 11:11 AM

    Alex's Avatar

    Hello.

    Any progress?

    Am I to correctly understand that customers/get/product/-/code/- will list every single invoice in the customer's history without limit?

    We are planning to make >a lot< of calls, and the prospect of getting back a huge XML document back every time is causing some concern.

    We need detailed invoice information very regularly (i.e every day) (dates, paid, item counts), but only for outstanding or pending invoices. Is there some kind of parameter available to limit the list to these? Even better would be being able to specify what data to retrieve in the request.

    Additionally, tracked items. We have like 5 (very volatile) tracked items at the moment, and this could easily grow to 20+ in the future. Imagine 1000 customers with 20 tracked items, that would make 20k HTTP calls per 24hrs purely to update usage. I'm fairly sure at this point CG would become unfeasible.

    Any advice or news regarding any of this?

  14. Support Staff 14 Posted by Marc Guyer on 03 Jun, 2012 12:27 AM

    Marc Guyer's Avatar

    Am I to correctly understand that customers/get/product/-/code/- will list every single invoice in the customer's history without limit?

    That is regretfully correct.

    We need detailed invoice information very regularly (i.e every day) (dates, paid, item counts), but only for outstanding or pending invoices. Is there some kind of parameter available to limit the list to these? Even better would be being able to specify what data to retrieve in the request.

    We've discussed several options but haven't decided on anything yet. Ideally, we'd like to fix this for everyone already using the call. In the end, we may have to deprecate the current functionality and introduce some default filters (paging, limited history, items on/off, etc).

    There is an undocumented call: customers/list which is much faster and returns limited information (pending invoice only). Usage is the same as customers/get. Does that help for the time being?

  15. 15 Posted by Alex on 03 Jun, 2012 12:40 AM

    Alex's Avatar

    I read the rest of this thread and tried out list but unfortunately it doesn't give enough information for our purposes (for example, we bring the billing date forward when a customer exceeds a threshold on current invoice charges).

    In any case, explicit filters would certainly be a benefit if they were added.

    (setItemQuantities too, but that's another API issue altogether).

  16. Support Staff 16 Posted by Marc Guyer on 04 Jun, 2012 12:52 PM

    Marc Guyer's Avatar

    I read the rest of this thread and tried out list but unfortunately it doesn't give enough information for our purposes (for example, we bring the billing date forward when a customer exceeds a threshold on current invoice charges).

    Hmm... I guess I'm not following you here. Can you explain this in more detail?

  17. 17 Posted by Alex on 04 Jun, 2012 01:09 PM

    Alex's Avatar

    Sure.

    We don't want our customers to go over a certain amount of charges at one time, as we're exposed to lose it all due to their ability to cancel their PayPal agreement.

    To counteract this, we sum their overages (by iterating through items on the customer/get call), and if the total is over an amount we bring forward the billing date to now.

    I was just observing that customers/list does not provide information about overages, so we're forced to use get.

    Hope that clears it up!

  18. Dean closed this discussion on 23 Jan, 2013 01:48 PM.

Discussions are closed to public comments.
If you need help with Cheddar please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

28 Mar, 2024 10:45 PM
24 Jan, 2024 08:33 AM
11 Jan, 2024 07:13 AM
30 Nov, 2023 02:07 AM
22 Nov, 2023 08:41 AM