Skip to content

A simple API made with Python to consume Spotify API for my personal use

License

Notifications You must be signed in to change notification settings

BubuDavid/Bubufy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues LinkedIn


Bubufy!

A simple API object that helps me to consume Spotify API data, and helps me with other projects.
Explore the docs »

· Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact

About The Project

I am currently working on a project based on the Spotify API consume, so I decided to create my own api object to make my life easier C: This is completely personalized to my needs and I will update it when I need it.

Getting Started

If you want to try it, you need a virtual environment with Python 3.9+ and pip installed in your computer.

Prerequisites

As I said above you will need Python 3.9+ and pip3 installed in your computer, also you will need to install some libraries, to do that you will need to download the project and run a pip command as you will see on the installation section.

Installation

  1. Get a free API Key and Secret at Spotify for Devs! Strong recommendation, set a Callback URI
  2. Install the library
      pip install bbfy
  3. Store you keys and Callback URI in a .env or another kind of secret file
  	SPOTIFY_CLIENT_ID=your actual client_id
  	SPOTIFY_CLIENT_SECRET=your actual client_secret
  	SPOTIFY_CALLBACK_URI=your actual callback_uri
  1. You are Ready

Usage

For now you can only recolect users info, the top tracks or artists for this user and the recently played tracks.And it is optimized to use with Flask and Django, I will use Flask on this next steps:

  1. Create a bubufy instance with your respective keys:
bubufy = Bubufy(client_id, client_secret, callback_uri)
  1. Get the authorization url and go to give access to use the API
auth_url = bubufy.get_auth_url()

You can access to this url through a button in your Flask, an example of this would be

@app.route('/route_name')
def method_name():
	context = {
		'auth_url': auth_url,
	}
	return render_template('template_name.html', **context)

And on your HTML could be something like:

<a href="{{ auth_url }}">Hi! Authorize me!</a>
  1. Give the app access, get the code from the redirect url and set the token with the following methods:
@app.route('/callback_uri')
def callback_name():
	code = request.args.get('code')
	bubufy.set_code_for_token(code)
	bubufy.set_token()
	return redirect(url_for('index')) # This for security or better UX
  1. And now you have a functional api in the bubufy object, you can make some things with it, for example, let's print the username in our page (Don't forget this is a flask project):
@app.route('/username')
def username_route():
	username = bubufy.get_user_data()['display_name']
	return username

You can make other things, I will soon update the documentation.

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Hi there! You want to contribute! Let me now how with your PR!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

David (Bubu) - @DBubu73 - [email protected]

Project Link: https://github.com/BubuDavid/Bubufy

About

A simple API made with Python to consume Spotify API for my personal use

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages