Python Package for Social Network Analytics
Project description
PySNA
Python Package for Social Network Analytics
Installation
The easiest way to install the latest version from PyPI is by using pip:
pip install pysna
You can also use Git to clone the repository from GitHub to install the latest development version:
git clone https://github.com/mathun3003/PySNA.git
cd PySNA
pip install .
Alternatively, install directly from the GitHub repository:
pip install git+https://github.com/mathun3003/PySNA.git
Quick Start
Import the API class for the Twitter API by writing:
from pysna import TwitterAPI
or import utility functions, too, by writing:
from pysna import *
Then, create an API instance by running:
api = TwitterAPI("BEARER_TOKEN", "CONSUMER_KEY", "CONSUMER_SECRET", "ACCESS_TOKEN", "ACCESS_TOKEN_SECRET")
and invoke a function:
api.user_info(...)
Find usage and output examples in the examples folder.
Functionalities
This package was designed to perform data analysis on Twitter data. It extends the official Twitter API by using the open-source package tweepy.
Thus, the following functions are added to the tweepy package:
user_info
tweet_info
compare_users
compare_tweets
Furthermore, some utility functions exist:
export_to_json
append_to_json
load_from_json
export_to_csv
append_to_csv
You can find further information on the Documentation.
CLI
The above mentioned functions are also available on the CLI.
To see the usage instructions and help, run:
pysna -h
If you wish to see the usage instructions for a function, run:
pysna <function> --help
For example, if you want to request a comparison of two users, you can run:
pysna compare-users "WWU_Muenster" "goetheuni" -c "tweets_count" "common_followers" -o "results.json" --return-timestamp
This will perform a comparison on the "WWU_Muenster"
and "goetheuni"
Twitter Accounts based on their number of composed Tweets and common followers. The results are exported to the results.json
file. Also, the timestamp of the request will be returned.
NOTE: Every request needs valid credentials for the official Twitter API. Thus, pass in a .env file to every function call by using the --env
flag or use the set-secrets
function to set the API secrets for upcoming requests (recommended). See the corresponding section in the documentation.
Notes
- Only Python >= 3.10 is supported.
- Only
.env
files are supported for the CLI, yet. - Use the
sample.local.env
to ensure functionality of the CLI tool.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pysna-0.1.3.tar.gz
.
File metadata
- Download URL: pysna-0.1.3.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f1f3e9aac0642d53a7c81dd9f2b024194bcf0b2c2a3d0d1cc3dc9549d3d065e |
|
MD5 | 7e1730856a2b890172a542daaf4ca75a |
|
BLAKE2b-256 | 5a25b1cfeb3be77349097ff4faecfce8089cd54e5ebab7b74dd3fee7dc0b024a |
File details
Details for the file pysna-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: pysna-0.1.3-py3-none-any.whl
- Upload date:
- Size: 23.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6ff273ad3a0ff16843dfe6b9af6ddb18113c7e1a5d1450cd0154b6eb4b42c38 |
|
MD5 | 9015879753902640d77e9aae2d065967 |
|
BLAKE2b-256 | bf8fa7f4bbcbcd8a4b46b5c21bf385be1cda68d71629f8b831887db746eb4226 |