Updated readme [Skip CI]
This commit is contained in:
parent
397f785232
commit
f266e247dc
16
README.md
16
README.md
@ -18,17 +18,19 @@ So far, the API wrapper is still considered unstable, a proper setup file is in
|
||||
# Use the demo server and credentials.
|
||||
>>> session = api.Session()
|
||||
# Or provide your own data.
|
||||
>>> session = api.Session(instance_url="https://demo.funkwhale.audio", username="demo", password="demo")
|
||||
>>> session = api.Session(instance_endpoint="https://demo.funkwhale.audio", username="demo", password="demo")
|
||||
# Alternatively, if you already have a JWT token you can pass it to the session class
|
||||
>>> session = api.Session(instance_url="https://demo.funkwhale.audio", token="xxxxxxxxx")
|
||||
# Do a login.
|
||||
>>> session = api.Session(instance_endpoint="https://demo.funkwhale.audio", token="xxxxxxxxx")
|
||||
# Do login.
|
||||
>>> session.login()
|
||||
# If username and password were provided, the login method generated already the JWT token. you can save this somewhere for passing it later.
|
||||
# If username and password were provided, the login method generated already the JWT token.
|
||||
# You can save this somewhere for passing it later.
|
||||
>>> print(session.token)
|
||||
xxxxxxxxx
|
||||
# Create the API object, that will be responsible for calling the funkwhale's server.
|
||||
>>> api = session.get_api()
|
||||
# all API calls follow the format "path.to.api.method(key=value, other_key=other_value)" (where method can be get and post).
|
||||
# all API calls follow the format "path.to.api.method(key=value, other_key=other_value)"
|
||||
# where method can be get and post.
|
||||
# Retrieve only 5 artists in the current instance.
|
||||
>>> artists = api.artists.get(page_size=5)
|
||||
# the data is always a dictionary and we can do something with it already.
|
||||
@ -41,8 +43,8 @@ Cortéz
|
||||
Solar Phasing
|
||||
Professor Kliq
|
||||
# Some methods have been modified a little from the original API paths due to pytohn's syntax.
|
||||
# For example, for retrieving all the libraries where an artist is added you should use /api/v1/artists/{id}/libraries
|
||||
# but in python-funkwhale it will be translated as the following call, just removing the {id} part from the path and passing it as an argument to the function.
|
||||
# For example, for calling /api/v1/artists/{id}/libraries
|
||||
# in python-funkwhale it will be translated as the following call, just removing the {id} part from the path and passing it as an argument to the function.
|
||||
>>> libraries = api.artists.libraries.get(1)
|
||||
>>> for i in libraries["results"]:
|
||||
... print(i["name"])
|
||||
|
Loading…
Reference in New Issue
Block a user