Git Product home page Git Product logo

aryaapi's Introduction

AryaAPI npm version

A JavaScript package that leverages Genius API to search and fetch song lyrics and album art.
It doesn't use any native node dependencies and therefore, can be used on the client-side.

Installation

Install with npm

npm install --save AryaAPI

Or install with Yarn

yarn add AryaAPI

Usage

Get the Genius Developer Access Token

import { GetLyrics, GetSong } from 'AryaAPI';
const options = {
	apiKey: '7251827XXXXXX',
	title: 'Alone',
	artist: 'Alan Walker',
	optimizeQuery: true
};

GetLyrics(options).then((lyrics) => console.log(lyrics));

GetSong(options).then((song) =>
	console.log(`
	${song.id}
	${song.title}
	${song.url}
	${song.albumArt}
	${song.lyrics}`)
);

โš ๏ธ You may get a CORS block error while testing on localhost. To bypass this, you need to disable Same-Origin Policy in your browser. You may follow the instructions Here.


Types

type options {
	title: string;
	artist: string;
	apiKey: string;		// Genius developer access token
	optimizeQuery?: boolean; // Setting this to true will optimize the query for best results
	authHeader?: boolean; // Whether to include auth header in the search request. 'false' by default.
}

๐Ÿšจ All properties in the options object are required except optimizeQuery and authHeader. If title or artist is unknown, pass an empty string.

type song {
	id: number;		// Genius song id
	title: string;          // Song title
	url: string;		// Genius webpage URL for the song
	lyrics: string;		// Song lyrics
	albumArt: string;	// URL of the album art image (jpg/png)
}

type SearchResult {
	id: number;		// Genius song id
	url: string;		// Genius webpage URL for the song
	title: string;		// Song title
	albumArt: string;	// URL of the album art image (jpg/png)
}

Methods

AryaAPI exposes the following methods:

GetLyrics(options | url)

Accepts Options or the url to a Genius song.
Returns a promise that resolves to a string containing lyrics. Returns null if no lyrics are found.

GetAlbumArt(options)

Accepts an Options object.
Returns a promise that resolves to a url (string) to the song's album art. Returns null if no url is found.

GetSong(options)

Accepts an Options object.
Returns a promise that resolves to an object of type song. Returns null if song is not found.

SearchSong(options)

Accepts an Options object.
Returns a promise that resolves to an array of type searchResult. Returns null if no matches are found.

GetSongById(id: (number | string))

Accepts a valid Genius song ID. IDs can be found using the SearchSong method.
Returns a promise that resolves to an object of type song.

Support

If you this repo is make you happy then support me by joining @CyberSupportGroup

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.