2 Replies Latest reply on Feb 22, 2017 12:58 PM by JP Kelly

    Using Twitter REST API to Retrieve JSON

    JP Kelly

      Hi All,

       

      As you may notice from my other posts, I don't have a background in coding so my question may seem a little stupid! Apologies if it does...

       

      So, I'm trying to work with Twitter data in Tableau. I know there's a built in feature in Tableau to do this, called web data connector, as detailed here: Tableau Junkie — Creating A Twitter Web Data Connector. However, I was wondering if there was a way of just grabbing the data via the Twitter REST API, in a compatible format such as JSON. I've managed to successfully run a search for a specific hashtag via the API console, and the results have been returned (in what looks to be JSON - a sample of which is below). However, I have no idea what to do now. If you copy and paste this info into a programme like datawrangler and save as .json, Tableau doesn't seem to recognise it (yes, I'm using the latest version and attempting to import via the JSON option). I've had a look around and I'm getting the sense that you have to do some work to this data before it can converted into a recognisable JSON format (parsing, I think they call it!) If anyone has any guidance on this or can recommend any beginner's tutorial (emphasis on the beginners), I'd be eternally grateful.

       

       

      Here's a sample of the data I got via the Twitter API:

       

      {
        "statuses": [
         {
        "created_at": "Fri Feb 10 16:31:12 +0000 2017",
        "id": 830091761297084400,
        "id_str": "830091761297084418",
        "text": "2 Days #TWD ❤",
        "truncated": false,
        "entities": {
        "hashtags": [
         {
        "text": "TWD",
        "indices": [
        7,
        11
        
      ]

        
      }

        
      ]
      ,
        "symbols": [],
        "user_mentions": [],
        "urls": []
        
      }
      ,
        "metadata": {
        "iso_language_code": "en",
        "result_type": "recent"
        
      }
      ,
        "source": "<a href="http://twitter.com/download/iphone" rel="nofollow">Twitter for iPhone</a>",
        "in_reply_to_status_id": null,
        "in_reply_to_status_id_str": null,
        "in_reply_to_user_id": null,
        "in_reply_to_user_id_str": null,
        "in_reply_to_screen_name": null,
        "user": {
        "id": 195358148,
        "id_str": "195358148",
        "name": "Cristina Shambi",
        "screen_name": "Cris_Shambi",
        "location": "Ecuador",
        "description": "Love God ☝  ❤️",
        "url": null,
        "entities": {
        "description": {
        "urls": []
        
      }

        
      }
      ,
        "protected": false,
        "followers_count": 140,
        "friends_count": 118,
        "listed_count": 0,
        "created_at": "Sun Sep 26 14:07:54 +0000 2010",
        "favourites_count": 232,
        "utc_offset": -21600,
        "time_zone": "Central Time (US & Canada)",
        "geo_enabled": true,
        "verified": false,
        "statuses_count": 351,
        "lang": "es",
        "contributors_enabled": false,
        "is_translator": false,
        "is_translation_enabled": false,
        "profile_background_color": "FF6699",
        "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/871773481/8575c9fa0e73ac210dfab303deb44046.png",
        "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/871773481/8575c9fa0e73ac210dfab303deb44046.png",
        "profile_background_tile": true,
        "profile_image_url": "http://pbs.twimg.com/profile_images/724932956956053504/AMHpmnor_normal.jpg",
        "profile_image_url_https": "https://pbs.twimg.com/profile_images/724932956956053504/AMHpmnor_normal.jpg",
        "profile_banner_url": "https://pbs.twimg.com/profile_banners/195358148/1360166313",
        "profile_link_color": "B40B43",
        "profile_sidebar_border_color": "FFFFFF",
        "profile_sidebar_fill_color": "E5507E",
        "profile_text_color": "362720",
        "profile_use_background_image": true,
        "has_extended_profile": true,
        "default_profile": false,
        "default_profile_image": false,
        "following": false,
        "follow_request_sent": false,
        "notifications": false,
        "translator_type": "none"
        
      }
      ,
        "geo": null,
        "coordinates": null,
        "place": null,
        "contributors": null,
        "is_quote_status": false,
        "retweet_count": 0,
        "favorite_count": 0,
        "favorited": false,
        "retweeted": false,
        "lang": "en"
        
      }
      ,
         {
        "created_at": "Fri Feb 10 16:31:01 +0000 2017",
        "id": 830091713372966900,
        "id_str": "830091713372966916",
        "text": "RT @WalkingDead_AMC: Their future is in their hands. #TWD returns this Sunday. https://t.co/htzNDHw5E4",
        "truncated": false,
        "entities": {
        "hashtags": [
         {
        "text": "TWD",
        "indices": [
        53,
        57
        
      ]

        
      }

        
      ]
      ,
        "symbols": [],
        "user_mentions": [
         {
        "screen_name": "WalkingDead_AMC",
        "name": "The Walking Dead AMC",
        "id": 65184105,
        "id_str": "65184105",
        "indices": [
        3,
        19
        
      ]

        
      }

        
      ]
      ,
        "urls": [],
        "media": [
         {
        "id": 829010643122479100,
        "id_str": "829010643122479104",
        "indices": [
        79,
        102
       

      And so on...