Skip to content

patrickian/Chirper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Chirper

Birds also chirp other than tweet!!
RESTFUL APIs that retrieves tweets from twitter using Twitter API.

How to run the project

Setting up and installing requirements

  1. Clone the repository https://github.com/patrickian/Chirper.git
  2. Install python. this project requires python 3.7.0
  3. Create a virtualenv. I recommend using pyenv and pyenv-virtualenv for controlling both your python version and your virtualenv.
  4. Install requirements.txt by running pip install -r requirements.txt in the project directory.

Creating your configs

  1. Signin your account in twitter. If you dont have an account, you can signup here.
  2. Apply for a twitter developer account. you can apply here.
  3. Once your application has been verified by twitter, you can now use the Twitter API!! Hoorayy :) please follow the instructions HERE on how to generate tokens to access Twitter API.
  4. Change directory inside the chirper folder and create your own secrets.json by copying the content of the secrets.json.template. Please put your Twitter API keys here.

Finishing up!

  1. run the migration. python manage.py migrate
  2. run the server. python manage.py runserver

How to use

NOTE: You can use limit parameter to control the number of tweets to retrieve.

Retrieving tweets based on User

You can retrieve tweets by user using the following endpoint.

/user/<your_user_here>/

Example

curl -H "Accept: application/json" -X GET http://localhost:xxxx/users/jdoe/?limit=20

Example response:

[
    "favorites": 68,
    "account": {
        "fullname": "John Doe",
        "url": "https://ti.co/onlysample",
        "id": 123123123
    },
    "date": "Mon Sep 14 08:09:03 +0000 2019",
    "text": "Sample tweet.SWEEEEEEET!!!!!",
    "hashtags": [
        "OneZeroOne"
    ],
    "retweets": 40
   ...
] 

Retrieving tweets based on Hashtag

You can retrieve tweets by hashtag by using the following endpoint.

/hashtags/<your_hashtag_here>/

Example

curl -H "Accept: application/json" -X GET http://localhost:xxxx/hashtags/python/?limit=20

Example response:

[
    "favorites": 96,
    "account": {
        "fullname": "Mary Jane",
        "url": "https://ti.co/onlysample101",
        "id": 687675547
    },
    "date": "Mon Sep 12 08:09:03 +0000 2019",
    "text": "Python can kill you!!Programmatically and literally. oops :)",
    "hashtags": [
        "python"
    ],
    "retweets": 19
   ...
] 

Running Test

You can run the following command to run unit tests: python manage.py test api.tests.TwitterTestCase

About

RESTFUL APIs that retrieves tweets from twitter using Twitter API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages