Python client for the Phish.net API
Project description
phishnetpy
phishnetpy is a Python client for the Phish.net API. It works with either Python 2 or 3 and supports all of the endpoints provided by api.phish.net.
Installation
You guessed it…
pip install phishnetpy
Getting Started
As you browse the Phish.net API documentation you will see that some API methods are labeled as “protected”. This means that in order to use those methods, you must generate an Application Key. To allow both public and protected usage, there are several setup steps you have to complete.
Public API Methods
For “public” or “unprotected” API calls, you simply need to instantiate the PhishNetAPI class, and call the methods for each of the API methods.
>>> from phishnetpy import PhishNetAPI
>>> phishnet = PhishNetAPI()
>>> artists = phishnet.artists_get()
>>> artists
[{'artist': 'Phish', 'slug': 'phish', 'artistid': '1'}, {'artist': 'Trey Anastasio', 'slug': 'trey-anastasio-band', 'artistid': '2'}, {'artist': 'Mike Gordon', 'slug': 'mike-gordon', 'artistid': '6'}, {'artist': 'Jon Fishman', 'slug': 'jon-fishman', 'artistid': '7'}, {'artist': 'Page McConnell', 'slug': 'page-mcconnell', 'artistid': '9'}]
Attempting to call protected methods without passing in an API key into the constructor will raise phishnetpy.exceptions.AuthError.
>>> phishnet.user_username_check("wilson")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "./phishnetpy/phishnetpy/decorators.py", line 16, in wrapper
raise AuthError("{} requires an API key".format(qual_name_safe(f)))
phishnetpy.exceptions.AuthError: PhishNetAPI.user_username_check requires an API key
Protected API Methods
In order to collect “protected” API methods, you must pass an API key into the constuctor.
>>> from phishnetpy import PhishNetAPI
>>> my_api_key = "<MY API KEY>" # Private API key from http://api.phish.net/keys/
>>> phishnet = PhishNetAPI(api_key=my_api_key)
>>> phishnet.user_username_check("wilson")
{'success': '0', 'reason': 'Sorry! wilson is already taken.'}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file phishnetpy-0.2.4.tar.gz
.
File metadata
- Download URL: phishnetpy-0.2.4.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46d0c17e6b700673723500437abc7a235a5470e6ae515c0ec8f9d13f70947b12 |
|
MD5 | 1a2b28a964094c7125bd5d365f60f543 |
|
BLAKE2b-256 | b6f2a7e55d9a4a1669a6358ae5abc88a4c9b191d54aa57a979743ff7e971cb85 |