baelorjs
node.js libary for the Baelor (Taylor Swift) API.
Contents
Installation
$ npm install baelorjs
Introduction
baelorjs is a simple node.js libary for the Baelor API.
- To obtain an API key, npm install baelorjs and run the Create a new API user example*
Below is a simple example which shows it fetching a list of albums.
var Baelor = ; // Include the node libaryvar client = // Create a new client api_key: "xxx" // Set the api_key, can be done later with .setKey(); client;
Examples
Here are some of the examples of the libary in use
Create an new API user
var Baelor = ; // Include the node libaryvar client = // Create a new client // We dont have an api key yet, so leave this blank; client;
Getting a list of album names
var Baelor = ; // Include the node libaryvar client = // Create a new client api_key: "xxx" // Set the api_key; client;
Find the longest line in a song
var Baelor = ; // Include the node libaryvar client = // Create a new client api_key: "xxx" // Set the api_key; client;
Object Types
There are multiple different object types that get returned by the APIs. To keep this doc clean, they will all be described up here instead of at each occurance.
Album Object
Description
An object that describes an album
Example
slug: "xxx" // Slug of the album name: "xxx" // Name of the album released_at: "xxxx-xx-xxTxx:xx:xx" // Release date length: "xx:xx:xx" label: "xxx" genres: // Array of genre keywords producers: // Array of producer names songs: // Array of Song Objects album_cover: image_id: "xxx" // image_id of Image Object
Song Object
Description
An object that describes a song
Example
slug: "xxx" // Slug of song title: "xxx" // Name of song length: "xx:xx:xx" // Length of song (time) writers: // Array of writer names producers: // Array of producer names album: {} // Album Objects
Image Object
Description
An object that describes an image
Example
data: "xxx" // String of image data (warning: raw data string) type: "xxx" // Mime type of image (eg image/png)
User Object
Description
An object that describes an api user
Example
username: "xxx" // Username email_address: "xxx" // Email address api_key: "xxx" // API key, is_admin: false // Has API admin rights
Error Object
Description
An object that describes an error
Example
status_code: 0 // Integer error description description: "xxx" // String representation of error details: // This holds additional error details. This can be null.
Supported APIs
.setKey(apikey)
Description
Sets the api key of the Baelor client to use in API requests. Not needed if you pass in the api_key at init.
Arguments
apikey
is your Baelor API key. You would acquire this calling .userCreate()- Required
Example
client;
.albums(values,callback)
Description
Gets a list of albums. Requires a client with an api key.
Arguments
values
is an object containing values that are required by the API- Has no arguments
callback
is called when the request completeserror
- if error occurs, returns an
Error Object
- else returns null
- if error occurs, returns an
albums
- returns an array of
Album Object
s
- returns an array of
Example
client;
.album(values,callback)
Description
Gets an album. Requires a client with an api key.
Arguments
values
is an object containing values that are required by the APIslug
is the slug of the album- Required
callback
is called when the request completeserror
- if error occurs, returns an
Error Object
- else returns null
- if error occurs, returns an
album
- returns an
Album Object
- returns an
Example
client;
.songs(values,callback)
Description
Gets a list of songs. Requires a client with an api key.
Arguments
values
is an object containing values that are required by the API- Has no arguments
callback
is called when the request completeserror
- if error occurs, returns an
Error Object
- else returns null
- if error occurs, returns an
songs
- returns an array of
Song Object
s
- returns an array of
Example
client;
.song(values,callback)
Description
Gets an song. Requires a client with an api key.
Arguments
values
is an object containing values that are required by the APIslug
is the slug of the song- Required
callback
is called when the request completeserror
- if error occurs, returns an
Error Object
- else returns null
- if error occurs, returns an
song
- returns a
Song Object
- returns a
Example
client;
.songLyrics(values,callback)
Description
Gets an songs lyrics. Requires a client with an api key.
Arguments
values
is an object containing values that are required by the APIslug
is the slug of the song- Required
callback
is called when the request completeserror
- if error occurs, returns an
Error Object
- else returns null
- if error occurs, returns an
lyrics
- returns a string of lyrics
Example
client;
.image(values,callback)
Description
Gets an image (To-Improve). Requires a client with an api key.
Arguments
values
is an object containing values that are required by the APIimage_id
is the id of an image. For example album artwork- Required
callback
is called when the request completeserror
- if error occurs, returns an
Error Object
- else returns null
- if error occurs, returns an
song
- returns an
Image Object
- returns an
Example
client;
.user(values,callback)
Description
Gets an API user.
Arguments
values
is an object containing values that are required by the API- Has no arguments
callback
is called when the request completeserror
- if error occurs, returns an
Error Object
- else returns null
- if error occurs, returns an
user
- returns a
User Object
- returns a
Example
client;
.userCreate(values,callback)
Description
Creates a new API user.
Arguments
values
is an object containing values that are required by the APIusername
is your desired username.- Required
- Must be between 1 and 25 characters long
- Must match
(?![\s])(?!.*[_-]{2})[a-zA-Z0-9-_]+(?
email
is your email address.- Required
- Must be a valid email address.
password
is your desired password.- Required
- Must be longer than 8 characters
- Must contain at least two of the following; number, lowercase letter, uppercase letter
callback
is called when the request completeserror
- if error occurs, returns an
Error Object
- else returns null
- if error occurs, returns an
user
- returns a
User Object
- returns a
Example
client;
Credz
Baelor API created by Alex Forbes-Reed @0xdeafcafe
baelorjs libary created by Jamie Davies @viralpickaxe