# API data storage

**URL:** <https://discuss.dev.twitch.com/t/api-data-storage/6757>\
**Category:** API\
**Created:** [July 2, 2016, 11:54pm UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757 "2016-07-02T23:54:52Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Streusel](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@Streusel](https://discuss.dev.twitch.com/u/Streusel)\
**Post date:** [July 2, 2016, 11:54pm UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/1 "2016-07-02T23:54:52Z")

</div>

This is basically a question similar to [Clarification on data storage restrictions](https://discuss.dev.twitch.com/t/clarification-on-data-storage-restrictions/1043)

Ok, so my question is what data are we actually allowed to store from the API?

I’m creating a website and I’d like to store the users bio, logo, their email, twitch id for the case that in the future twitch does decide to allow users to change their username, the total viewer count, follower count, current/last game played (e.g. Mario Cart 64) & current viewer count if the stream is online.

The “user data” portion and “channel metadata” portion feel ambiguous and feel like they were specifically worded to be vague. ([https://www.twitch.tv/user/legal?page=api\_terms\_of\_service](https://www.twitch.tv/user/legal?page=api_terms_of_service))

As it is this is how I currently see what data belongs to which and therefore isn’t allowed to be stored.  
User Data:

- Bio
- Email
- Account creation date
- ID
- Profile picture

Channel Data:

- Game name
- Total viewer count
- Follower count

Stream Data: (allowed)

- Viewer count

If we are not in fact allowed to store any of the above for periods longer than 24 hours, how can we go about creating sites that require similar data to socialblade/loots/streamhatchet and others?

Specifically, I would like to be able to store some of the data that is returned from [http://api.twitch.tv/kraken/channels/twitch](http://api.twitch.tv/kraken/channels/twitch) and [https://api.twitch.tv/kraken/streams?channel=twitch](https://api.twitch.tv/kraken/streams?channel=twitch) and later expand into more.  
Could we get some information as to why the 24hour limit exists? As well as what data specifically is meant? You’ve done such a good job at explaining why/when the auth token must be deleted.

---

<div class="post-metadata">

**Author:** ![Streusel](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@Streusel](https://discuss.dev.twitch.com/u/Streusel)\
**Post date:** [July 9, 2016, 12:38am UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/2 "2016-07-09T00:38:02Z")

</div>

Shameful bump.

---

<div class="post-metadata">

**Author:** ![Not\_My\_Name](https://avatars.discourse-cdn.com/v4/letter/n/54ee81/32.png) [@Not\_My\_Name](https://discuss.dev.twitch.com/u/Not_My_Name)\
**Post date:** [July 9, 2016, 3:36pm UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/3 "2016-07-09T15:36:31Z")

</div>

I would also like to know this. Additionally, is there an ID that never changes? Right now I am using the username as unique identifier, but if Twitch ever decided to allow to change this, it would really screw up my application.

“Twitch user data for users not created by your application may be stored for no more than twenty-four (24) hours.”

Interpreted literally, this means we can not store anything useful from Twitch like emails and usernames. We need more info. If we can’t store the username and other useful info for authentication, this makes the Twitch API nearly useless.

---

<div class="post-metadata">

**Author:** ![Streusel](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@Streusel](https://discuss.dev.twitch.com/u/Streusel)\
**Post date:** [July 9, 2016, 11:48pm UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/4 "2016-07-09T23:48:35Z")

</div>

> [@Not\_My\_Name](#):
>
> Additionally, is there an ID that never changes? Right now I am using the username as unique identifier, but if Twitch ever decided to allow to change this, it would really screw up my application.

There is \_id which is the twitch id of the user, that id never changes.  
[https://api.twitch.tv/kraken/channels/twitch](https://api.twitch.tv/kraken/channels/twitch) would be an example of where \_id (12826) exists. [https://api.twitch.tv/kraken/users/twitch](https://api.twitch.tv/kraken/users/twitch) confirms that the \_id (12826) is the same and persists.

---

<div class="post-metadata">

**Author:** ![Not\_My\_Name](https://avatars.discourse-cdn.com/v4/letter/n/54ee81/32.png) [@Not\_My\_Name](https://discuss.dev.twitch.com/u/Not_My_Name)\
**Post date:** [July 10, 2016, 2:03am UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/5 "2016-07-10T02:03:01Z")

</div>

Yeah, I ended up rewriting to use the \_id instead.

```
function authenticated_user($access_token) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://api.twitch.tv/kraken/user');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Authorization: OAuth '.$access_token
    ));
	
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	
    $output = curl_exec($ch);
    $response = json_decode($output, true);
    curl_close($ch);

    return $response;		
}

```

For future searches.  
$response[’\_id’]

---

<div class="post-metadata">

**Author:** ![DallasNChains](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dallasnchains/32/1608_2.png) [@DallasNChains](https://discuss.dev.twitch.com/u/DallasNChains)\
**Post date:** [July 11, 2016, 3:06am UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/6 "2016-07-11T03:06:27Z")

</div>

More to come on this soon! Sorry for the delay!

---

<div class="post-metadata">

**Author:** ![Streusel](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@Streusel](https://discuss.dev.twitch.com/u/Streusel)\
**Post date:** [July 12, 2016, 3:56am UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/7 "2016-07-12T03:56:48Z")

</div>

Thank you!  
Looking forward to it 🙂

---

<div class="post-metadata">

**Author:** ![Streusel](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@Streusel](https://discuss.dev.twitch.com/u/Streusel)\
**Post date:** [July 26, 2016, 3:11pm UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/8 "2016-07-26T15:11:26Z")

</div>

@DallasNChains any updates?

---

<div class="post-metadata">

**Author:** ![DallasNChains](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dallasnchains/32/1608_2.png) [@DallasNChains](https://discuss.dev.twitch.com/u/DallasNChains)\
**Post date:** [July 26, 2016, 3:29pm UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/9 "2016-07-26T15:29:39Z")

</div>

No updates yet! I’ll keep you posted. 🙂

---

<div class="post-metadata">

**Author:** ![proto\_baggins](https://avatars.discourse-cdn.com/v4/letter/p/5e9695/32.png) [@proto\_baggins](https://discuss.dev.twitch.com/u/proto_baggins)\
**Post date:** [August 1, 2016, 9:31pm UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/10 "2016-08-01T21:31:28Z")

</div>

I think that if we understood the motivation behind a time-restricted retention policy, we might be able to make better judgement calls when faced with uncertainty.

What perceptions are we agreeing to protect?

---

<div class="post-metadata">

**Author:** ![proto\_baggins](https://avatars.discourse-cdn.com/v4/letter/p/5e9695/32.png) [@proto\_baggins](https://discuss.dev.twitch.com/u/proto_baggins)\
**Post date:** [August 23, 2016, 10:30pm UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/11 "2016-08-23T22:30:50Z")

</div>

> [@DallasNChains](#):
>
> No updates yet! I’ll keep you posted. 🙂

Is there any movement on this?  
If no one is able to explain the restriction **and** no one particularly cares what we store or for how long, then why not remove it from the TOS?

---

<div class="post-metadata">

**Author:** ![DallasNChains](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dallasnchains/32/1608_2.png) [@DallasNChains](https://discuss.dev.twitch.com/u/DallasNChains)\
**Post date:** [August 23, 2016, 11:00pm UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/12 "2016-08-23T23:00:55Z")

</div>

We’re updating our ToS from top-to-bottom. More to come soon.

---

<div class="post-metadata">

**Author:** ![DallasNChains](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dallasnchains/32/1608_2.png) [@DallasNChains](https://discuss.dev.twitch.com/u/DallasNChains)\
**Post date:** [August 24, 2016, 8:35pm UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/13 "2016-08-24T20:35:26Z")

</div>

Here is a thread on the new terms. [New Developer Agreement and Terms of Service](https://discuss.dev.twitch.com/t/new-developer-agreement-and-terms-of-service/7212)

---

<div class="post-metadata">

**Author:** ![proto\_baggins](https://avatars.discourse-cdn.com/v4/letter/p/5e9695/32.png) [@proto\_baggins](https://discuss.dev.twitch.com/u/proto_baggins)\
**Post date:** [August 24, 2016, 10:56pm UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/14 "2016-08-24T22:56:09Z")

</div>

Well done, thanks for this.

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [September 23, 2016, 10:56pm UTC](https://discuss.dev.twitch.com/t/api-data-storage/6757/15 "2016-09-23T22:56:29Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
