https://github.com/ramusus/django-twitter-api
Django implementation for Twitter API based on Django models
https://github.com/ramusus/django-twitter-api
Last synced: 4 months ago
JSON representation
Django implementation for Twitter API based on Django models
- Host: GitHub
- URL: https://github.com/ramusus/django-twitter-api
- Owner: ramusus
- License: bsd-3-clause
- Created: 2013-04-27T16:00:14.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2016-04-15T13:21:22.000Z (over 10 years ago)
- Last Synced: 2025-12-15T07:46:46.828Z (7 months ago)
- Language: Python
- Size: 125 KB
- Stars: 32
- Watchers: 7
- Forks: 16
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Django Twitter API
[](https://travis-ci.org/ramusus/django-twitter-api) [](https://coveralls.io/r/ramusus/django-twitter-api)
Application for interacting with Twitter API objects using Django model interface
## Installation
pip install django-twitter-api
Add into `settings.py` lines:
INSTALLED_APPS = (
...
'oauth_tokens',
'm2m_history',
'taggit',
'twitter_api',
)
# oauth-tokens settings
OAUTH_TOKENS_HISTORY = True # to keep in DB expired access tokens
OAUTH_TOKENS_TWITTER_CLIENT_ID = '' # application ID
OAUTH_TOKENS_TWITTER_CLIENT_SECRET = '' # application secret key
OAUTH_TOKENS_TWITTER_USERNAME = '' # user login
OAUTH_TOKENS_TWITTER_PASSWORD = '' # user password
## Usage examples
### Simple API request
>>> from twitter_api.utils import api
>>> response = api('get_status', 327926550815207424)
>>> response.text
'@mrshoranweyhey Thanks for the love! How about a follow for a follow? :) ^LF'
>>> response.source_url
'http://www.exacttarget.com/social'
>>> response = api('get_user', 'BarackObama')
>>> response.id, response.name
(813286, 'Barack Obama')
### Fetch status by ID
>>> from twitter_api.models import Status
>>> status = Status.remote.fetch(327926550815207424)
>>> status
>>> status.in_reply_to_status
### Fetch user by ID and user name
>>> from twitter_api.models import User
>>> User.remote.fetch(813286)
>>> User.remote.fetch('BarackObama')
### Fetch statuses of user
>>> from models import User
>>> user = User.remote.fetch(813286)
>>> user.fetch_statuses(count=30)
[,
,
,
...]
### Fetch followers of user
>>> from twitter_api.models import User
>>> user = User.remote.fetch(813286)
>>> user.fetch_followers(all=True)
[, , , '...(remaining elements truncated)...']
### Fetch retweets of status
>>> from twitter_api.models import Status
>>> status = Status.remote.fetch(329231054282055680)
>>> status.fetch_retweets()
[,
,
,
...]
### Fetch replies of status
>>> from twitter_api.models import Status
>>> status = Status.remote.fetch(536859483851735040)
>>> status.fetch_replies()
[,
,
,
...]
>>> status.replies_count
6