justintv / Twitch-API

A home for details about our API
www.twitch.tv
1.72k stars 379 forks source link

Implement a way to be able to get resubs #347

Open kinsi55 opened 9 years ago

kinsi55 commented 9 years ago

Hi,

Since currently there is no way to detect re-subs besides using the twitchnotify chat, i'd suggest adding a updated_at field to the subscriptions api which updates to the current date whenever a automatic resub happens. This would make stuff a lot easier for a lot of people. I had a talk in the forum regarding this too: http://discuss.dev.twitch.tv/t/without-relying-on-the-chat-notification-what-would-be-the-best-way-to-go-about-polling-subs/1835/3

BarryCarlyon commented 9 years ago

You can math calculate (izl made me correct it) the number of months based on the already existing created_at key

DorCoMaNdO commented 9 years ago

@BarryCarlyon While it would probably work for subscriptions that weren't cancelled and then renewed, subs that were cancelled and then renewed get a new created_at key (according to my tests over my personal subscriptions) even when renewed within a month (which keeps the count for months going, which is also another variable to consider if created_at would remain from the first subscription, what happens when I cancel and resub 29 days later? The count would continue but a calculation script would detect another month).

While an option to get how many subscriptions a user had to a channel would be great, getting that information from an active subscription is not the best way in my opinion, I'd hope to see an overhaul to the subscriptions API, letting us see each individual subscription of a user to a channel (that means that inactive subscriptions would be included as well), a total value would be nice there as well as more detail over each subscription (start date, cancel date, and if continued, for how long?), and to keep current applications that use the current API still functional without any changes, viewing inactive subscriptions could be optional, enabled by a parameter such as "showinactive=1".

EDIT: The changes I suggested to the API would also let applications see if someone has been subscribed before without caching data.

kinsi55 commented 9 years ago

@BarryCarlyon Pretty much what @DorCoMaNdO said, its not possible to calculate it really. What i had to do to get more or less "relieable" data is combine the api and chat together. Whenever a subscription is active for more than 32 days from the last known re-sub date, i see it as a new subscription, unless the twitchnotify chatmessage notified me beforehand of the re-sub. When calculating the subscriptions, for one example user that has been subbed for 6 months, at the exact time i got a re-sub message in the chat i took his created_at key and subtracted that date from the date the chat message was send. This gave me that each subscription lasted 31.5 something days, which doesnt make sense.

expertsonline commented 9 years ago

+1 ... been waiting for something like this for 1.5 years now.

All we really need is an updated_at date which would be something that already happens, when the payment is processed as the users get the option to broadcast their re-sub in chat.

Other similar threads with discussions on this topic: https://github.com/justintv/Twitch-API/issues/141 http://discuss.dev.twitch.tv/t/re-payment-notification-for-subs/293 https://groups.google.com/d/msg/twitch-api/KyvEAV9t5qU/7ADM9xB7ZzEJ

BarryCarlyon commented 9 years ago

@kinsi55 @DorCoMaNdO I phrased badly I think

What we really need I suppose is a webhook… But thats another story.

Doing Math will work out nicely-ish how long a automatic renewal has been alive. And may do so for a manual resub within the right timeframe.

Theres no sensible way. You could do it but keeping a (daily) record of all subs, and if you get a gap you can see it, and account for it to see a resub.

My sub notifiers currently ignore automatics, since I'm 99% API based instead of relying on Twitchnotify, so really I'm just ignoring the purple button all together. I do ned to think more on the subject, but inb4 Twitch changes it again…