22
Twitter API Keys for creating an awesome application !

20130504 - FeWeb - Twitter API

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: 20130504  - FeWeb - Twitter API

Twitter APIKeys for creating an awesome application !

Page 2: 20130504  - FeWeb - Twitter API

Pascal Alberty@zorrobiwan

CTO Managing Partner

Page 3: 20130504  - FeWeb - Twitter API

Twitter Dev Ecosystem

● Twitter success○ Thanks Dev Community !

● API○ September 2006○ Very complete○ Open○ Free

https://blog.twitter.com/2006/introducing-twitter-api

Page 4: 20130504  - FeWeb - Twitter API

The APIs

● APIs○ Search API○ REST API○ Streaming API○ https://dev.twitter.com/docs/history-rest-search-api

● Versions○ API version 1 (almost deprecated)○ API version 1.1

Page 5: 20130504  - FeWeb - Twitter API

Resources

https://dev.twitter.com/

(Drupal )

Page 6: 20130504  - FeWeb - Twitter API

Authentication

● OAuth○ Each API request must be authorized○ Access token on behalf of a Twitter user

● Obtaining access token○ Sign in with Twitter○ 3-legged OAuth○ Pin based OAuth○ dev.twitter.com○ ...

https://twitter.com/settings/applications

Page 7: 20130504  - FeWeb - Twitter API

Declare your application

https://dev.twitter.com/apps/new

Page 8: 20130504  - FeWeb - Twitter API

Rate limiting

● Rate limit window duration○ 15 minutes

● Requests allotted○ per user○ via application-only auth

● Example○ GET statuses/user_timeline○ per user: 150 requests per 15 minutes○ via app: 300 requests per 15 minutes

https://dev.twitter.com/docs/rate-limiting/1.1/limits

Page 9: 20130504  - FeWeb - Twitter API

Other technical limits

● Direct messages○ 250 per day

● Tweets○ 1,000 per day○ Retweets are counted as Tweets.

● Changes to account email○ Four per hour

● Following○ 1,000 per day

● Following (account-based)○ up to following 2,000 other users

Page 10: 20130504  - FeWeb - Twitter API

Platform objects

● Tweets can be found alone, within user objects, but most often within timelines

● Users can be found tweeting, following, and favoriting on Twitter

● Entities are most often found within Tweets● Places can be found throughout the natural universe,

but typically only appear attached to Tweets on Twitter

Page 11: 20130504  - FeWeb - Twitter API

Objects type

● JSON !

● XML output will be dropped soon○ Only JSON output with API 1.1

● Be careful with ids (64 bits)○ use String version (especially if using Javascript)○ Twitpocalypse

■ https://dev.twitter.com/docs/twitter-ids-json-and-snowflake○ Idpocalypse

■ https://dev.twitter.com/blog/64-bit-twitter-user-idpocalypse

Page 14: 20130504  - FeWeb - Twitter API

Entities / Entity Example

● Hashtags, Medias, URLs, User mentions, Symbols

● No need to parse● Data used for display also (ex: display_url)

Page 15: 20130504  - FeWeb - Twitter API

Place example

https://api.twitter.com/1/geo/id/247f43d441defc03.json

Page 16: 20130504  - FeWeb - Twitter API

Libraries

● PHP○ Twitter-async (https://github.com/jmathai/twitter-

async)○ tmhOAuth (https://github.

com/themattharris/tmhOAuth)○ Zend Framework (http://framework.zend.

com/manual/1.12/en/zend.service.twitter.html)● Java

○ Twitter4J (http://twitter4j.org/)

https://dev.twitter.com/docs/twitter-libraries

Page 17: 20130504  - FeWeb - Twitter API

Tools

● Twurl○ https://github.com/marcel/twurl○ "curl" for Twitter API○ Manage access tokens (authentication)

● Apigee Console○ https://apigee.com/console○ Free console to execute APIs

Page 18: 20130504  - FeWeb - Twitter API

Search API

● Similar to http://search.twitter.com

● Criteria○ terms○ geocode○ language ("Language detection is best-effort")○ count, until, since-id, max-id○ result type: mixed, recent, popular○ include entities

● Paginated !○ you have to manage this by yourself

Page 19: 20130504  - FeWeb - Twitter API

REST API

● Timelines● Tweets● Direct Messages● Friends & Followers● Users● Suggested Users● Favorites● Lists● Saved Searches● Places & Geo● Trends● Spam Reporting● OAuth● Help

Page 20: 20130504  - FeWeb - Twitter API

Streaming API

● Persistent HTTP connection○ until you decide to close it

● Could be reeeeaaaaaaally huge !○ Think about you architecture (hard and soft) !○ Separate storage and consumption

● Only one stream opened at a time

● Could be tricky to managed○ Use a library

Page 21: 20130504  - FeWeb - Twitter API

Streaming API endpoints groups

● Public Streams○ GET statuses/sample○ POST statuses/filter○ GET statuses/firehose (limited access)

● User Streams○ Data and events for a specific user

● Site Streams (beta and limited access)○ Real time update for large number of users

Page 22: 20130504  - FeWeb - Twitter API

Twitter APIKeys for creating an awesome application !

https://twitter.com/zorrobiwan/status/341888609399480323