An API is the core business asset that differentiates one Mobile App or the business as a whole to another. The digital footprint and the marketing approaches of the businesses are driven using the custom mobile app development and website development. While managing Web Application Development and Mobile Application Development projects, one of essential milestones is to identify the APIs required to implement desired functionalities.

And we, at LetsNurture are the ones who have the expertise to guide you on the basis of your project needs. Over the course of 9 years, we have experience on Payment Gateway API implementation and integration, Third party API integration, Third party Social Network API integration and robust API development too. Now, let’s see what Twitch offers us.

Introduction to Twitch

Twitch is a very powerful platform which provides live streaming videos such as sports games.

Twitch brings brands, game publishers, and viewers together with strategic ad solutions in a social video environment. If you are thinking to build your own platform using Twitch, they are providing a wide range of APIs from their Twitch v5 API documents.

Range of APIs and use of them

Bits

Bits is providing the “Get Cheermotes” endpoint API. API integration using this we can get the available cheermotes and animated emotes.

Channel Feed

Channel feed is providing the multiple endpoint APIs, so let’s discuss them one by one.

> Get Multiple Feed Posts

Using this endpoint API we can get the post on the specified channel. And it will return multiple posts form the specified channel.

> Get Feed Post

This endpoint API used for to get the single post for the specified channel feed.

> Create Feed Post
Whenever we required creating feed post for the specified channel then we have to use this endpoint API and “content” parameter is required for this API.

> Delete Feed Post
Using this endpoint API we can delete a particular post from the specified channel.

> Create Reaction to a Feed Post
This endpoint API is used for the create reaction to the specified post in the specified channel. We can create reaction either by id or by the string.

> Delete Reaction to a Feed Post
Using this endpoint API you can delete reaction from the specified post. And this action can be performed either by id or by a string.

Every request must include your application’s client ID, either explicitly or implicitly by including an OAuth token. If you use an OAuth token in your request, the API figures out the client ID for you.

For the demonstration, I am sending API request with PHP cURL.

For example, if you want to display top videos from twitch you can play around with “Get Top Videos” API reference. Get Top Videos is based on view count, optionally filtered by game or time period.

Example of request returns to the top video objects for the Overwatch game during the past month.

// Authentication: None
// URL: https://api.twitch.tv/kraken/videos/top?period=month&game=Overwatch

<?php
$channelsApi = 'https://api.twitch.tv/kraken/games/top';
$clientId = 'k0b9h5i9hb8a9aqb474a503wtig9qi';
$ch = curl_init();
curl_setopt_array($ch, array(
    CURLOPT_HTTPHEADER => array(
        'Client-ID: ' . $clientId,
        'Accept: application/vnd.twitchtv.v5+json',
    ),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_URL => $channelsApi
));
$response = curl_exec($ch);
curl_close($ch);
?>

And you will get the top game response in JSON format like:

{
    "vods": [{
      "_id": "v101568088",
      "broadcast_id": 23680870240,
      "broadcast_type": "highlight",
      "channel": {
            "_id": "28230875",
            "display_name": "Talespin",
            "name": "talespin"
      },
      "created_at": "2016-11-17T06:24:46Z",
      "description": "gg",
      "description_html": "gg<br>",
      "fps": {
         "chunked": 59.9726125301009,
         "high": 29.9993664424577,
         "low": 30.0000611327453,
         "medium": 29.9993664424577,
         "mobile": 30.0000611327453
      },
      "game": "Overwatch",
      "language": "en",
      "length": 1272,
      "preview": {
         "large": "https://static-cdn.jtvnw.net/s3_vods/e273175ca1_talespin_23680870240_548725280//thumb/thumb101568088-640x360.jpg",
         "medium": "https://static-cdn.jtvnw.net/s3_vods/e273175ca1_talespin_23680870240_548725280//thumb/thumb101568088-320x180.jpg",
         "small": "https://static-cdn.jtvnw.net/s3_vods/e273175ca1_talespin_23680870240_548725280//thumb/thumb101568088-80x45.jpg",
         "template": "https://static-cdn.jtvnw.net/s3_vods/e273175ca1_talespin_23680870240_548725280//thumb/thumb101568088-{width}x{height}.jpg"
      },
      "published_at": "2016-11-17T06:24:46Z",
      "resolutions": {
         "chunked": "1280x720",
         "high": "1280x720",
         "low": "640x360",
         "medium": "852x480",
         "mobile": "400x226"
      },
      "status": "recorded",
      "tag_list": "overwatch talespin pharah reinhardt ggez",
      "thumbnails": {
         "large": [{
            "type": "generated",
            "url": "https://static-cdn.jtvnw.net/s3_vods/e273175ca1_talespin_23680870240_548725280//thumb/thumb101568088-640x360.jpg"
         }],
         "medium": [{
            "type": "generated",
            "url": "https://static-cdn.jtvnw.net/s3_vods/e273175ca1_talespin_23680870240_548725280//thumb/thumb101568088-320x180.jpg"
         }],
         "small": [{
            "type": "generated",
            "url": "https://static-cdn.jtvnw.net/s3_vods/e273175ca1_talespin_23680870240_548725280//thumb/thumb101568088-80x45.jpg"
         }],
         "template": [{
            "type": "generated",
            "url": "https://static-cdn.jtvnw.net/s3_vods/e273175ca1_talespin_23680870240_548725280//thumb/thumb101568088-{width}x{height}.jpg"
         }]
      },
      "title": "Talespin vs Gods 1v1 (Pharah & Reinhardt)",
      "url": "https://www.twitch.tv/talespin/v/101568088",
      "viewable": "public",
      "viewable_at": null,
      "views": 16426
   },
   ...
   ]
}

Get live streams API:
This gets a list of the 25 live streams of Overwatch with the most current viewers.

// Authentication: None
// URL: https://api.twitch.tv/kraken/streams/?game=Overwatch

<?php
$channelsApi = 'https://api.twitch.tv/kraken/streams/?game=Overwatch';
$clientId = 'k0b9h5i9hb8a9aqb474a503wtig9qi';
$ch = curl_init();
curl_setopt_array($ch, array(
    CURLOPT_HTTPHEADER => array(
        'Client-ID: ' . $clientId,
        'Accept: application/vnd.twitchtv.v5+json',
    ),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_URL => $channelsApi
));
$response = curl_exec($ch);
curl_close($ch);
?>

And you will get live streams response in JSON format like:

{
   "_total": 1295,
   "streams": [
   {
      "_id": 23937446096,
      "average_fps": 60,
      "channel": {
            "_id": 121059319,
            "broadcaster_language": "en",
            "created_at": "2016-04-06T04:12:40Z",
            "display_name": "MOONMOON_OW",
            "followers": 251220,
            "game": "Overwatch",
            "language": "en",
            "logo": "https://static-cdn.jtvnw.net/jtv_user_pictures/moonmoon_ow-profile_image-0fe586039bb28259-300x300.png",
            "mature": true,
            "name": "moonmoon_ow",
            "partner": true,
            "profile_banner": "https://static-cdn.jtvnw.net/jtv_user_pictures/moonmoon_ow-profile_banner-13fbfa1ba07bcd8a-480.png",
            "profile_banner_background_color": null,
            "status": "KKona where my Darryl subs at KKona",
            "updated_at": "2016-12-15T20:04:53Z",
            "url": "https://www.twitch.tv/moonmoon_ow",
            "video_banner": "https://static-cdn.jtvnw.net/jtv_user_pictures/moonmoon_ow-channel_offline_image-2b3302e20384eee8-1920x1080.png",
            "views": 9869754
      },
      "created_at": "2016-12-15T14:55:49Z",
      "delay": 0,
      "game": "Overwatch",
      "is_playlist": false,
      "preview": {
            "large": "https://static-cdn.jtvnw.net/previews-ttv/live_user_moonmoon_ow-640x360.jpg",
            "medium": "https://static-cdn.jtvnw.net/previews-ttv/live_user_moonmoon_ow-320x180.jpg",
            "small": "https://static-cdn.jtvnw.net/previews-ttv/live_user_moonmoon_ow-80x45.jpg",
            "template": "https://static-cdn.jtvnw.net/previews-ttv/live_user_moonmoon_ow-{width}x{height}.jpg"
      },
      "video_height": 720,
      "viewers": 11523
   },
      ...
   ]
}

Reference URL: https://dev.twitch.tv/docs

What LetsNurture offers for Robust API integration and development?

As an web or mobile application development company, you must be having a routine requirement of third party API integration or robust API development for your Mobile App development projects. Therefore, while you manage the development of the other functionalities of your Project, a skilled development partner can look after your API development tasks.

LetsNurture, a leading IT outsourcing company, has been prominent for almost a decade in the domains of custom mobile app development and web applications development. We provide custom Business Solutions that adds significant value to your development needs. We understand the custom requirements such as custom API & Web Services development are essential to such Projects. You can hire API developers who have been experts in this area of API integration and API development from us.

Have something to share on the same or wish to hire API developers from LetsNurture? Get a quote after free consultation now. Tweet us on Twitter @letsnurture or drop a post on the official Facebook page of LetsNurture. Share your thoughts with us, we will be happy to have a discussion on the same.

Happy Coding 😉

Want to work with us? We're hiring!