Created
February 16, 2012 16:03
-
-
Save dominiek/1846017 to your computer and use it in GitHub Desktop.
Example definition of the Twitter API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Example service definition for Twitter | |
*/ | |
{ | |
id: 'twitter', | |
name: 'Twitter', | |
url: 'http://twitter.com/', | |
siteName: 'Twitter.com', | |
rest: { | |
// Global REST configurations that are inherited by all subsequent definitions | |
host: 'api.twitter.com', | |
format: 'json', | |
paramConversions: { | |
'numItems': 'count', | |
'sinceId': 'since_id' | |
} | |
} | |
facilities: { | |
'native_reposts': true | |
}, | |
collections: [ | |
// Mentions collection | |
{ | |
id: 'activity/mentions', | |
outbound: { | |
objectType: 'activity', // This tells us what we are retrieving | |
rest: { | |
path: '/1/statuses/mentions.json', | |
params: { | |
include_rts: true | |
} | |
} | |
requiresAuthentication: true, | |
maxCount: 200, | |
recommendedCount: 50 | |
} | |
}, | |
// User timeline, e.g. Tweets of @dominiek | |
{ | |
id: 'activity/person', | |
outbound: { | |
objectType: 'activity', | |
target: { // Target tells us something about the context | |
objectType: 'person', | |
}, | |
rest: { | |
path: '/1/statuses/user_timeline.json', | |
paramConversions: { | |
'target.id': 'user_id', | |
'target.displayName': 'screen_name' | |
}, | |
params: { | |
include_entities: true | |
} | |
}, | |
requiresAuthentication: true, | |
maxCount: 200, | |
recommendedCount: 120 | |
} | |
}, | |
// List timeline, e.g. getting the tweets of list x | |
{ | |
id: 'activity/group', | |
outbound: { | |
objectType: 'activity', | |
target: { | |
objectType: 'group', | |
}, | |
rest: { | |
path: '/1/lists/statuses.json', | |
paramConversions: { | |
'target.id': 'list_id' | |
}, | |
params: { | |
include_entities: true | |
} | |
}, | |
requiresAuthentication: true, | |
maxCount: 200, | |
recommendedCount: 40 | |
} | |
}, | |
// User endpoint, e.g. profile of @dominiek | |
{ | |
id: 'person', | |
outbound: { | |
objectType: 'person', // We are returning users, not activity in this case | |
target: { | |
objectType: 'person', | |
}, | |
rest: { | |
path: '/1/users/show.json', | |
paramConversions: { | |
'target.id': 'user_id', | |
'target.displayName': 'screen_name' | |
}, | |
params: { | |
include_entities: true | |
} | |
} | |
requiresAuthentication: true | |
} | |
}, | |
// Posting a new message | |
{ | |
id: 'activity/posts', | |
outbound: { | |
objectType: 'activity', | |
verb: 'post', | |
rest: { | |
path: '/1/statuses/status.json', | |
method: 'post', | |
paramConversions: { | |
'activity.title': 'status' | |
} | |
} | |
requiresAuthentication: true, | |
maxTitleLength: 140 | |
} | |
}, | |
// Liking a message | |
{ | |
id: 'activity/likes', | |
inbound: { | |
objectType: 'activity', | |
verb: 'like', | |
rest: { | |
path: '/1/favorites/create.json', | |
method: 'post', | |
paramConversions: { | |
'activity.object.id': 'id' | |
} | |
} | |
requiresAuthentication: true | |
} | |
}, | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment