{"_id":"56ad21651c09150d00a183a0","parentDoc":null,"__v":9,"category":{"_id":"56ad20660ab3c00d00ce3347","__v":11,"pages":["56ad21651c09150d00a183a0","56ad235c693f0a0d0085f0c3","56ad24afd21f1b0d00fd2f86","56ad2e5b1c09150d00a183a6","56ad305879011b0d00c32aaa","56ad30c81a7ee417009ced18","56ad31432a7860170013f711","56ad33b21a7ee417009ced1a","56ad34a0b9ac5517006b6962","56ad35503fc1020d009776e1","56e7266bdbc36117006a41ff"],"project":"56acd71213ac890d001c3c7a","version":"56acd71213ac890d001c3c7d","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-30T20:43:18.400Z","from_sync":false,"order":9,"slug":"singularity-real-time-events","title":"Singularity: Real-Time Events"},"githubsync":"","project":"56acd71213ac890d001c3c7a","user":"56acd6caa040860d00ac94a2","version":{"_id":"56acd71213ac890d001c3c7d","project":"56acd71213ac890d001c3c7a","__v":15,"createdAt":"2016-01-30T15:30:26.928Z","releaseDate":"2016-01-30T15:30:26.928Z","categories":["56acd71313ac890d001c3c7e","56acd8f113ac890d001c3c81","56acd8f95ac4060d0027865e","56acd93a13ac890d001c3c82","56ad20660ab3c00d00ce3347","56ad356a2a7860170013f714","56ad47eb0ab3c00d00ce334f","56afd523bc304a0d00ace1df","56b29a019621f20d00efb37e","56b657e11bc6970d009feee7","5845cc3c39950c1b002afe77","5845cde163c11b250037967e","5846efd45d064323007b17b4","588604da4674e32300efd160","588627882393d50f00f1322c"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-01-30T20:47:33.473Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"This Event is Part of an Event Chain\",\n  \"body\": \"This event is called as soon as channel gains a new subscriber and is always followed by the **subscriber-benefits-change** event.\"\n}\n[/block]\nUsing Socket.IO, this event can be listened to as follows:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"socket.on('subscriber-new', function(data){\\n    //Do something\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThis event fires whenever a channel gains a new subscriber and has the following JSON structure:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \" {\\n   event: \\\"subscriber-new\\\",\\n   channel_id: \\\"channel identifier \\\",\\n   channel: {\\n      names: {\\n         gamewisp: \\\"GameWisp channel name\\\",\\n         twitch: \\\"twitch channel name\\\",\\n         youtube: \\\"youtube channel name\\\"\\n      },\\n      ids: {\\n         gamewisp: \\\"channel identifier\\\",\\n         twitch: \\\"12312312q\\\",\\n         youtube: \\\"UCiqp4J8asdkssssssssdfae\\\"\\n      }  \\n   },\\n   data: {\\n      ids: {\\n         gamewisp: \\\"26356\\\",\\n         twitch: \\\"46984772\\\"\\n      },\\n      usernames: {\\n         gamewisp: \\\"user_name\\\",\\n         twitch: \\\"user_name_twitch\\\"\\n      },\\n      status: \\\"active\\\",\\n      amount: \\\"3.99\\\",\\n      subscribed_at: \\\"2015-12-30 00:00:00\\\",\\n      end_of_access: \\\"2016-01-30 23:59:00\\\",\\n      tier: {\\n         id: \\\"111111\\\",\\n         title: \\\"Tier Title\\\",\\n         level: \\\"1\\\",\\n         cost: \\\"3.99\\\",\\n         description: \\\"Tier description\\\",\\n         published: true\\n      }\\n   }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe **data** object is described as follows:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Property\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"ids\",\n    \"0-1\": \"Object\",\n    \"0-2\": \"Contains the id and username information of the subscriber. See: [Real-Time Events Basics](https://gamewisp.readme.io/docs/real-time-events).\",\n    \"1-0\": \"status\",\n    \"1-1\": \"String\",\n    \"1-2\": \"The subscriber’s current status. Can be any of the following:\\n\\n* **active** - a currently active subscriber \\n* **trial** - a subscriber on a trial code \\n* **grace_period** - a canceled subscriber that is still received benefits \\n* **billing_grace_period** - a canceled subscriber still receiving benefits that was canceled due to a payment processing error \\n* **inactive** - a subscriber that is canceled and receiving no benefits \\n* **twitch** - a subscriber that is receiving free benefits from a partnered Twitch streamer.\",\n    \"2-0\": \"amount\",\n    \"2-1\": \"String - US Currency\",\n    \"2-2\": \"The amount currently paid by the subscriber. Does not currently include additional money paid by the subscriber over the cost of their subscription tier.\",\n    \"3-0\": \"subscribed_at\",\n    \"3-1\": \"String formatted UTC DateTime\",\n    \"3-2\": \"The date and time at which the subscriber subscribed to the channel. Is null in the case of an inactive subscriber\",\n    \"4-0\": \"end_of_access\",\n    \"4-1\": \"String formatted UTC DateTime\",\n    \"4-2\": \"The date and time at which the subscriber is set to be renewed.\",\n    \"5-0\": \"tier\",\n    \"5-1\": \"Object\",\n    \"5-2\": \"A JSON object describing the tier to which the subsciber is subscribed.\"\n  },\n  \"cols\": 3,\n  \"rows\": 6\n}\n[/block]\nThis event fires as soon as a subscriber has newly subscribed to a channel. It is always immediately followed by the subscriber-benefits-change event.","excerpt":"The Singularity event used to notify apps when a channel gets a new subscriber","slug":"subscriber-new","type":"fn","title":"subscriber-new"}

subscriber-new

The Singularity event used to notify apps when a channel gets a new subscriber

[block:callout] { "type": "warning", "title": "This Event is Part of an Event Chain", "body": "This event is called as soon as channel gains a new subscriber and is always followed by the **subscriber-benefits-change** event." } [/block] Using Socket.IO, this event can be listened to as follows: [block:code] { "codes": [ { "code": "socket.on('subscriber-new', function(data){\n //Do something\n});", "language": "javascript" } ] } [/block] This event fires whenever a channel gains a new subscriber and has the following JSON structure: [block:code] { "codes": [ { "code": " {\n event: \"subscriber-new\",\n channel_id: \"channel identifier \",\n channel: {\n names: {\n gamewisp: \"GameWisp channel name\",\n twitch: \"twitch channel name\",\n youtube: \"youtube channel name\"\n },\n ids: {\n gamewisp: \"channel identifier\",\n twitch: \"12312312q\",\n youtube: \"UCiqp4J8asdkssssssssdfae\"\n } \n },\n data: {\n ids: {\n gamewisp: \"26356\",\n twitch: \"46984772\"\n },\n usernames: {\n gamewisp: \"user_name\",\n twitch: \"user_name_twitch\"\n },\n status: \"active\",\n amount: \"3.99\",\n subscribed_at: \"2015-12-30 00:00:00\",\n end_of_access: \"2016-01-30 23:59:00\",\n tier: {\n id: \"111111\",\n title: \"Tier Title\",\n level: \"1\",\n cost: \"3.99\",\n description: \"Tier description\",\n published: true\n }\n }\n}", "language": "json" } ] } [/block] The **data** object is described as follows: [block:parameters] { "data": { "h-0": "Property", "h-1": "Type", "h-2": "Description", "0-0": "ids", "0-1": "Object", "0-2": "Contains the id and username information of the subscriber. See: [Real-Time Events Basics](https://gamewisp.readme.io/docs/real-time-events).", "1-0": "status", "1-1": "String", "1-2": "The subscriber’s current status. Can be any of the following:\n\n* **active** - a currently active subscriber \n* **trial** - a subscriber on a trial code \n* **grace_period** - a canceled subscriber that is still received benefits \n* **billing_grace_period** - a canceled subscriber still receiving benefits that was canceled due to a payment processing error \n* **inactive** - a subscriber that is canceled and receiving no benefits \n* **twitch** - a subscriber that is receiving free benefits from a partnered Twitch streamer.", "2-0": "amount", "2-1": "String - US Currency", "2-2": "The amount currently paid by the subscriber. Does not currently include additional money paid by the subscriber over the cost of their subscription tier.", "3-0": "subscribed_at", "3-1": "String formatted UTC DateTime", "3-2": "The date and time at which the subscriber subscribed to the channel. Is null in the case of an inactive subscriber", "4-0": "end_of_access", "4-1": "String formatted UTC DateTime", "4-2": "The date and time at which the subscriber is set to be renewed.", "5-0": "tier", "5-1": "Object", "5-2": "A JSON object describing the tier to which the subsciber is subscribed." }, "cols": 3, "rows": 6 } [/block] This event fires as soon as a subscriber has newly subscribed to a channel. It is always immediately followed by the subscriber-benefits-change event.