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_infotweet_infocompare_userscompare_tweets
Furthermore, some utility functions exist:
export_to_jsonappend_to_jsonload_from_jsonexport_to_csvappend_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
.envfiles are supported for the CLI, yet. - Use the
sample.local.envto ensure functionality of the CLI tool.
Metadata
Release files for pysna 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pysna-0.1.3.tar.gz | 27.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pysna-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 50.8 kB
Release files / pysna-0.1.3.tar.gz
| Download URL | pysna-0.1.3.tar.gz |
|---|---|
| Size | 27.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f1f3e9aac0642d53a7c81dd9f2b024194bcf0b2c2a3d0d1cc3dc9549d3d065e
|
|
BLAKE2b-256 checksum How to use checksums |
5a25b1cfeb3be77349097ff4faecfce8089cd54e5ebab7b74dd3fee7dc0b024a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.17
|
Release files / pysna-0.1.3-py3-none-any.whl
| Download URL | pysna-0.1.3-py3-none-any.whl |
|---|---|
| Size | 23.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a6ff273ad3a0ff16843dfe6b9af6ddb18113c7e1a5d1450cd0154b6eb4b42c38
|
|
BLAKE2b-256 checksum How to use checksums |
bf8fa7f4bbcbcd8a4b46b5c21bf385be1cda68d71629f8b831887db746eb4226
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.17
|