SlideShare a Scribd company logo
1 of 24
Gathering Data from Twitter
Marcello Tomasini – mtomasini@my.fit.edu
Marcos Oliveira – moliveirajun2013@my.fit.edu
Adapted from 2013 Hugo Serrano’s and 2014 Diogo Pacheco’s Lectures
Introduction
▪ What is Twitter
▪ Twitter is an online social network that allows users
to send and read messages of up to 140
characters, known as tweets.
▪ https://twitter.com
Introduction
▪ Twitter
▪ Online Social Network
▪ Users can follow and be followed by other users.
▪ A Real Time Information Network
▪ Tweets can be replied, retweeted, and favorited.
Twitter APIs
▪ REST APIs
▪ Access core primitives of Twitter
▪ provides programmatic access to read and write Twitter data
▪ Author a new Tweet, retweet a Tweet, read author profile and follower data,
and more
▪ Search API
▪ Finding a set of Tweets, Tweets from a particular user, or Tweets with
specific keywords/hashtags
▪ focused on relevance and not completeness
▪ Streaming APIs
▪ Continuously deliver new responses to REST API queries
▪ Useful for Data Mining & Analytics research
▪ When application is rate-limited for over-polling the REST APIs
▪ Large quantity of keywords
▪ Ads APIs
▪ https://dev.twitter.com/overview/documentation
REST APIs
▪ Communicate over HTTP with the same HTTP
verbs (GET, POST)
▪ Twitter limits the number of requests per 15
minutes intervals
▪ https://dev.twitter.com/rest/public/rate-limiting
▪ https://dev.twitter.com/rest/public/rate-limits
▪ Detailed reference of Search API endpoint
▪ https://dev.twitter.com/rest/public/search
▪ https://dev.twitter.com/rest/reference/get/search/
tweets
Streaming APIs
▪ Low latency access to Twitter’s global stream of Tweet
data.
▪ Twitter offers several streaming endpoints
▪ Public Streams
▪ https://dev.twitter.com/streaming/public
▪ Streams of the public data flowing through Twitter.
▪ Suitable for following specific users or topics, and data mining
▪ User Streams
▪ https://dev.twitter.com/streaming/userstreams
▪ Contain roughly all of the data corresponding with a single user’s view of Twitter.
▪ Site Streams
▪ https://dev.twitter.com/streaming/sitestreams
▪ Multi-user version of user streams. Site streams are intended for servers which must
connect to Twitter on behalf of many users.
▪ Require a long-lived HTTP connection
API Objects
▪ The most frequently observed objects in Twitter
ecosystem:
▪ Tweets
▪ Users
▪ Entities
▪ Places
API Object: Tweets
▪ Basic building blocks
▪ Also known as “status updates”
▪ Fields such as
▪ created_at: UTC time when this Tweet was created.
▪ coordinates: the geographic location of this Tweet.
▪ in_reply_to_screen_name: the name of the original Tweet's
author.
▪ in_reply_to_status_id: the id of the original Tweet's author.
▪ retweeted_status: a representation of the original Tweet that
was retweeted.
▪ https://dev.twitter.com/overview/api/tweets
API Object: Users
▪ They tweet, follow, retweet, are mentioned etc.
▪ Fields such as:
▪ id: the unique identification of a user
▪ screen_name: the screen name, handle, or alias that this
user identifies themselves with
▪ followers_count: the number of followers this account
currently has
▪ https://dev.twitter.com/overview/api/users
API Object: Entities
▪ Provide metadata and additional information about
content posted on Twitter:
▪ media
▪ urls
▪ hashtags
▪ user_mentions
▪ https://dev.twitter.com/overview/api/entities
▪ https://dev.twitter.com/overview/api/entities-in-
twitter-objects
API Objects: Places
▪ Specific, named locations with corresponding geo
coordinates
▪ Tweets associated with places are not necessarily
issued from that location but could also potentially
be about that location
▪ Fields such as
▪ country
▪ bounding_box
▪ full_name
▪ place_type
▪ https://dev.twitter.com/overview/api/places
Twitter APIs: OAuth Authentication
▪ Create a Twitter profile
▪ Create an application (you need a phone number)
▪ Create Access Tokens
▪ Use the OAuth tool to get your keys, tokens and
secrets
▪ https://apps.twitter.com
Twitter Libraries
▪ For some libraries (python), the Twitter API website is
the documentation for the developers
▪ https://dev.twitter.com/overview/api/twitter-libraries
-> api.search.tweets(q=“#HowToComplexNetworks”)
Useful Hints
▪ Get accustomed with Twitter App
Useful Hints
▪ Try first Twitter Console before coding
https://dev.twitter.com/rest/tools/console
Useful Hints
▪ Check rate limits in your code – try/catch loops
▪ Do you need database? Relational one?
▪ Remember 2-step process:
▪ Collect data
▪ Construct the network
▪ Intensive traffic/volume, try MongoDB
Useful Hints?
▪ 2014 FIFA World Cup Dataset
▪ +50 millions tweets
▪ +1 million geo-tagged tweets
▪ 1 month window period
▪ Database Optimization
▪ Memory Consuming
▪ Programs Crashes
Twitter api resources
Twitter API - Resources
▪ Timelines
▪ Search
▪ Tweets
▪ Streaming
▪ Direct Messages
▪ Friends & Followers
▪ Users
▪ Suggested Users
▪ Favorites
▪ Lists
▪ Saved Searches
▪ Places & Geo
▪ Trends
▪ Spam Reporting
▪ OAuth
▪ Help
Twitter API - Resources
▪ Search
▪ Let’s search for 5 most recent tweets with “Florida
Tech” on it
▪ Let’s search for 5 most recent tweets within 1mi
Twitter API – Resources
▪ Friends & Followers
▪ Let’s query for the friends of a particular user
▪ Let’s query for the first 100 followers of a particular
user
Twitter API - Resources
▪ Users
▪ Let’s query for the usernames of the first 100
followers of a particular user
© Ronaldo Menezes, Florida Tech
Twitter API - Resources
▪ Streaming
▪ Let’s track tweets with the hashtag #cse5656 and
#netsci
▪ Let’s track the tweets in Brevard County
Questions?
Marcello Tomasini – mtomasini@my.fit.edu
Marcos Oliveira – moliveirajun2013@my.fit.edu
http://my.fit.edu/~mtomasini/classes/ComplexNetworks.html

More Related Content

Similar to Gather Twitter Data Using APIs

Development of Twitter Application #1 - Overview
Development of Twitter Application #1 - OverviewDevelopment of Twitter Application #1 - Overview
Development of Twitter Application #1 - OverviewMyungjin Lee
 
Social media analysis in R using twitter API
Social media analysis in R using twitter API Social media analysis in R using twitter API
Social media analysis in R using twitter API Mohd Shadab Alam
 
Linkedin & OAuth
Linkedin & OAuthLinkedin & OAuth
Linkedin & OAuthUmang Goyal
 
Twitter Trend Analyzer
Twitter Trend AnalyzerTwitter Trend Analyzer
Twitter Trend AnalyzerMatthew Chang
 
Twitter Timeline and Search Distributed System.pptx
Twitter Timeline and Search Distributed System.pptxTwitter Timeline and Search Distributed System.pptx
Twitter Timeline and Search Distributed System.pptxMd. Rakib Trofder
 
Twitter: A Hands-On Learning Session for Researcher
Twitter: A Hands-On Learning Session for ResearcherTwitter: A Hands-On Learning Session for Researcher
Twitter: A Hands-On Learning Session for ResearcherKMb Unit, York University
 
Spring Social - Messaging Friends & Influencing People
Spring Social - Messaging Friends & Influencing PeopleSpring Social - Messaging Friends & Influencing People
Spring Social - Messaging Friends & Influencing PeopleGordon Dickens
 
Mz twitter-1.1-sdl
Mz twitter-1.1-sdlMz twitter-1.1-sdl
Mz twitter-1.1-sdlAngus Fox
 
20130504 - FeWeb - Twitter API
20130504  - FeWeb - Twitter API20130504  - FeWeb - Twitter API
20130504 - FeWeb - Twitter APIPascal Alberty
 
Tweet Archivist presentation
Tweet Archivist presentationTweet Archivist presentation
Tweet Archivist presentationBNRichards
 
STC Summit 2015: API Documentation, an Example-Based Approach
STC Summit 2015: API Documentation, an Example-Based ApproachSTC Summit 2015: API Documentation, an Example-Based Approach
STC Summit 2015: API Documentation, an Example-Based ApproachLois Patterson
 
How not to be all a flutter about Twitter
How not to be all a flutter about TwitterHow not to be all a flutter about Twitter
How not to be all a flutter about TwitterMargaret Hazel
 
Create Salesforce online IDE in 30 minutes
Create Salesforce online IDE in 30 minutesCreate Salesforce online IDE in 30 minutes
Create Salesforce online IDE in 30 minutesJitendra Zaa
 
APIエコノミー時代の認証・認可
APIエコノミー時代の認証・認可APIエコノミー時代の認証・認可
APIエコノミー時代の認証・認可Tatsuo Kudo
 
Fun! with the Twitter API
Fun! with the Twitter APIFun! with the Twitter API
Fun! with the Twitter APIErin Shellman
 
South JVM Users Group Talk - Building Social Media Tools using JVM Supported ...
South JVM Users Group Talk - Building Social Media Tools using JVM Supported ...South JVM Users Group Talk - Building Social Media Tools using JVM Supported ...
South JVM Users Group Talk - Building Social Media Tools using JVM Supported ...Anand Hemmige
 

Similar to Gather Twitter Data Using APIs (20)

Development of Twitter Application #1 - Overview
Development of Twitter Application #1 - OverviewDevelopment of Twitter Application #1 - Overview
Development of Twitter Application #1 - Overview
 
Social media analysis in R using twitter API
Social media analysis in R using twitter API Social media analysis in R using twitter API
Social media analysis in R using twitter API
 
Twitter api
Twitter apiTwitter api
Twitter api
 
Linkedin & OAuth
Linkedin & OAuthLinkedin & OAuth
Linkedin & OAuth
 
Twitter Trend Analyzer
Twitter Trend AnalyzerTwitter Trend Analyzer
Twitter Trend Analyzer
 
Twitter Timeline and Search Distributed System.pptx
Twitter Timeline and Search Distributed System.pptxTwitter Timeline and Search Distributed System.pptx
Twitter Timeline and Search Distributed System.pptx
 
Twitter System Design
Twitter System DesignTwitter System Design
Twitter System Design
 
Twitter
TwitterTwitter
Twitter
 
Twitter: A Hands-On Learning Session for Researcher
Twitter: A Hands-On Learning Session for ResearcherTwitter: A Hands-On Learning Session for Researcher
Twitter: A Hands-On Learning Session for Researcher
 
Spring Social - Messaging Friends & Influencing People
Spring Social - Messaging Friends & Influencing PeopleSpring Social - Messaging Friends & Influencing People
Spring Social - Messaging Friends & Influencing People
 
Mz twitter-1.1-sdl
Mz twitter-1.1-sdlMz twitter-1.1-sdl
Mz twitter-1.1-sdl
 
20130504 - FeWeb - Twitter API
20130504  - FeWeb - Twitter API20130504  - FeWeb - Twitter API
20130504 - FeWeb - Twitter API
 
Tweet Archivist presentation
Tweet Archivist presentationTweet Archivist presentation
Tweet Archivist presentation
 
STC Summit 2015: API Documentation, an Example-Based Approach
STC Summit 2015: API Documentation, an Example-Based ApproachSTC Summit 2015: API Documentation, an Example-Based Approach
STC Summit 2015: API Documentation, an Example-Based Approach
 
How not to be all a flutter about Twitter
How not to be all a flutter about TwitterHow not to be all a flutter about Twitter
How not to be all a flutter about Twitter
 
Twet
TwetTwet
Twet
 
Create Salesforce online IDE in 30 minutes
Create Salesforce online IDE in 30 minutesCreate Salesforce online IDE in 30 minutes
Create Salesforce online IDE in 30 minutes
 
APIエコノミー時代の認証・認可
APIエコノミー時代の認証・認可APIエコノミー時代の認証・認可
APIエコノミー時代の認証・認可
 
Fun! with the Twitter API
Fun! with the Twitter APIFun! with the Twitter API
Fun! with the Twitter API
 
South JVM Users Group Talk - Building Social Media Tools using JVM Supported ...
South JVM Users Group Talk - Building Social Media Tools using JVM Supported ...South JVM Users Group Talk - Building Social Media Tools using JVM Supported ...
South JVM Users Group Talk - Building Social Media Tools using JVM Supported ...
 

Recently uploaded

Data Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxData Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxFurkanTasci3
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改atducpo
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一F La
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDRafezzaman
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...soniya singh
 

Recently uploaded (20)

Data Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxData Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptx
 
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
 
Decoding Loan Approval: Predictive Modeling in Action
Decoding Loan Approval: Predictive Modeling in ActionDecoding Loan Approval: Predictive Modeling in Action
Decoding Loan Approval: Predictive Modeling in Action
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
 

Gather Twitter Data Using APIs

  • 1. Gathering Data from Twitter Marcello Tomasini – mtomasini@my.fit.edu Marcos Oliveira – moliveirajun2013@my.fit.edu Adapted from 2013 Hugo Serrano’s and 2014 Diogo Pacheco’s Lectures
  • 2. Introduction ▪ What is Twitter ▪ Twitter is an online social network that allows users to send and read messages of up to 140 characters, known as tweets. ▪ https://twitter.com
  • 3. Introduction ▪ Twitter ▪ Online Social Network ▪ Users can follow and be followed by other users. ▪ A Real Time Information Network ▪ Tweets can be replied, retweeted, and favorited.
  • 4. Twitter APIs ▪ REST APIs ▪ Access core primitives of Twitter ▪ provides programmatic access to read and write Twitter data ▪ Author a new Tweet, retweet a Tweet, read author profile and follower data, and more ▪ Search API ▪ Finding a set of Tweets, Tweets from a particular user, or Tweets with specific keywords/hashtags ▪ focused on relevance and not completeness ▪ Streaming APIs ▪ Continuously deliver new responses to REST API queries ▪ Useful for Data Mining & Analytics research ▪ When application is rate-limited for over-polling the REST APIs ▪ Large quantity of keywords ▪ Ads APIs ▪ https://dev.twitter.com/overview/documentation
  • 5. REST APIs ▪ Communicate over HTTP with the same HTTP verbs (GET, POST) ▪ Twitter limits the number of requests per 15 minutes intervals ▪ https://dev.twitter.com/rest/public/rate-limiting ▪ https://dev.twitter.com/rest/public/rate-limits ▪ Detailed reference of Search API endpoint ▪ https://dev.twitter.com/rest/public/search ▪ https://dev.twitter.com/rest/reference/get/search/ tweets
  • 6. Streaming APIs ▪ Low latency access to Twitter’s global stream of Tweet data. ▪ Twitter offers several streaming endpoints ▪ Public Streams ▪ https://dev.twitter.com/streaming/public ▪ Streams of the public data flowing through Twitter. ▪ Suitable for following specific users or topics, and data mining ▪ User Streams ▪ https://dev.twitter.com/streaming/userstreams ▪ Contain roughly all of the data corresponding with a single user’s view of Twitter. ▪ Site Streams ▪ https://dev.twitter.com/streaming/sitestreams ▪ Multi-user version of user streams. Site streams are intended for servers which must connect to Twitter on behalf of many users. ▪ Require a long-lived HTTP connection
  • 7. API Objects ▪ The most frequently observed objects in Twitter ecosystem: ▪ Tweets ▪ Users ▪ Entities ▪ Places
  • 8. API Object: Tweets ▪ Basic building blocks ▪ Also known as “status updates” ▪ Fields such as ▪ created_at: UTC time when this Tweet was created. ▪ coordinates: the geographic location of this Tweet. ▪ in_reply_to_screen_name: the name of the original Tweet's author. ▪ in_reply_to_status_id: the id of the original Tweet's author. ▪ retweeted_status: a representation of the original Tweet that was retweeted. ▪ https://dev.twitter.com/overview/api/tweets
  • 9. API Object: Users ▪ They tweet, follow, retweet, are mentioned etc. ▪ Fields such as: ▪ id: the unique identification of a user ▪ screen_name: the screen name, handle, or alias that this user identifies themselves with ▪ followers_count: the number of followers this account currently has ▪ https://dev.twitter.com/overview/api/users
  • 10. API Object: Entities ▪ Provide metadata and additional information about content posted on Twitter: ▪ media ▪ urls ▪ hashtags ▪ user_mentions ▪ https://dev.twitter.com/overview/api/entities ▪ https://dev.twitter.com/overview/api/entities-in- twitter-objects
  • 11. API Objects: Places ▪ Specific, named locations with corresponding geo coordinates ▪ Tweets associated with places are not necessarily issued from that location but could also potentially be about that location ▪ Fields such as ▪ country ▪ bounding_box ▪ full_name ▪ place_type ▪ https://dev.twitter.com/overview/api/places
  • 12. Twitter APIs: OAuth Authentication ▪ Create a Twitter profile ▪ Create an application (you need a phone number) ▪ Create Access Tokens ▪ Use the OAuth tool to get your keys, tokens and secrets ▪ https://apps.twitter.com
  • 13. Twitter Libraries ▪ For some libraries (python), the Twitter API website is the documentation for the developers ▪ https://dev.twitter.com/overview/api/twitter-libraries -> api.search.tweets(q=“#HowToComplexNetworks”)
  • 14. Useful Hints ▪ Get accustomed with Twitter App
  • 15. Useful Hints ▪ Try first Twitter Console before coding https://dev.twitter.com/rest/tools/console
  • 16. Useful Hints ▪ Check rate limits in your code – try/catch loops ▪ Do you need database? Relational one? ▪ Remember 2-step process: ▪ Collect data ▪ Construct the network ▪ Intensive traffic/volume, try MongoDB
  • 17. Useful Hints? ▪ 2014 FIFA World Cup Dataset ▪ +50 millions tweets ▪ +1 million geo-tagged tweets ▪ 1 month window period ▪ Database Optimization ▪ Memory Consuming ▪ Programs Crashes
  • 19. Twitter API - Resources ▪ Timelines ▪ Search ▪ Tweets ▪ Streaming ▪ Direct Messages ▪ Friends & Followers ▪ Users ▪ Suggested Users ▪ Favorites ▪ Lists ▪ Saved Searches ▪ Places & Geo ▪ Trends ▪ Spam Reporting ▪ OAuth ▪ Help
  • 20. Twitter API - Resources ▪ Search ▪ Let’s search for 5 most recent tweets with “Florida Tech” on it ▪ Let’s search for 5 most recent tweets within 1mi
  • 21. Twitter API – Resources ▪ Friends & Followers ▪ Let’s query for the friends of a particular user ▪ Let’s query for the first 100 followers of a particular user
  • 22. Twitter API - Resources ▪ Users ▪ Let’s query for the usernames of the first 100 followers of a particular user
  • 23. © Ronaldo Menezes, Florida Tech Twitter API - Resources ▪ Streaming ▪ Let’s track tweets with the hashtag #cse5656 and #netsci ▪ Let’s track the tweets in Brevard County
  • 24. Questions? Marcello Tomasini – mtomasini@my.fit.edu Marcos Oliveira – moliveirajun2013@my.fit.edu http://my.fit.edu/~mtomasini/classes/ComplexNetworks.html