Unofficial IPFS python library for interacting with Pinata APIs
Run the following to install:
pip install pinata
- Register an account on Pinata
- Create a new api key on api keys page
- Copy your api key, api secret and secret key to be used below.
from pinata import Pinata
pinata = Pinata(ap_key, secret_key, access_token)
To upload your file to Pinata, you can either provide:
- Directory path of the file you want to upload
- File itself as a Byte Stream, eg. If from flask request:
file = request.files["file_name"]
Finally,
from pinata import Pinata
pinata = Pinata(ap_key, secret_key, access_token)
response = pinata.pin_file(file)
print(response)
To unpin a file, you will need the file's IpfsHash.
from pinata import Pinata
pinata = Pinata(ap_key, secret_key, access_token)
response = pinata.unpin_file(ipfs_hash)
print(response)
If you want to get all pins in your account:
from pinata import Pinata
pinata = Pinata(ap_key, secret_key, access_token)
response = pinata.get_pins()
print(response)