Design - kristinedomingo/cs373-idb GitHub Wiki

#RESTful API http://docs.sweetmusic.apiary.io

Search

The route for searching allows a user to search the database and even specific tables for specific search terms. The resultant set will be in the form:

{ "and": {...}, "or": {...} }

  • and - lists results that contain all the terms
  • or - lists results that contain specific terms

This allows the user to decide if having all the terms is important or if certain words should be ranked higher. If having both terms in the resulting set is important then the and dictionary returned will be useful. If you want to rank importance by term then the or dictionary returned will be useful.

GET Searching ALL Tables

search/all?searchterm={terms}
The search/all will search for terms in each table. In the 'and' dictionary, there will be dictionaries for each individual table. In the 'or' dictionary, there will be separate dictionaries for each term and in those dictionaries will be separate dictionaries for each term with their results.

Parameters

  • searchterm (string, required) - a string of the terms searched

GET Searching Artist Table

search/artists?searchterm={terms}
The search/artists will search for terms in the artist table only. The behavior will be similar to the all tables but the results will only include artists.

Parameters

  • searchterm (string, required) - a string of the terms searched

GET Searching Album Table

search/albums?searchterm={terms}
The search/albums will search for terms in the album table only. The behavior will be similar to the all tables but the results will only include albums.

Parameters

  • searchterm (string, required) - a string of the terms searched

GET Searching Track Table

search/tracks?searchterm={terms}
The search/tracks will search for terms in the track table only. The behavior will be similar to the all tables but the results will only include tracks.

Parameters

  • searchterm (string, required) - a string of the terms searched

Artists

The routes below are for getting information regarding Artists. Ideally the artist specific API would be able to do two things:

  1. Provide a List of Arbitrary Artists
  2. Provide Specific Artists

GET List of Arbitrary Artists

/artists/{page_num}?psize={psize}&sort={col_attr}&order={asc_desc}
This GET request will return an array of artists with their information. The use case would be to generate enough artists to display on the Artists tab's table for at least one page.

Parameters

  • page_num (number, required) - used as an offset to query by page
  • psize (number, optional) - used to specify the size of the list
  • col_attr (string, optional) - takes a specific column to sort the list of artists by
  • asc_desc (string, optional) - default ascending sort order, can set to descending with 'desc'

col_attr sort options

  • artist_name
  • num_albums
  • recent_album
  • top_track
  • popularity

GET Specific Artist(s)

/artists?ids={artist_ids}
This GET request will return an array of artists. The artists are determined by the ids provided, where {artist_ids} is a comma separated list of artists.

Parameters

  • artist_ids (string, required) - comma separated list of spotify ids

Albums

The routes below are for getting information regarding Albums. Ideally the album specific API would be able to do two things:

  1. Provide a List of Arbitrary Albums
  2. Provide Specific Albums

GET List of Arbitrary Albums

/albums/{page_num}?psize={psize}&sort={col_attr}&order={asc_desc}
This GET request will return an array of albums with their information. The use case would be to generate enough albums to display on the Album tab's table for at least one page.

Parameters

  • page_num (number, required) - used as an offset to query by page
  • psize (number, optional) - used to specify the size of the list
  • col_attr (string, optional) - takes a specific column to sort the list of albums by
  • asc_desc (string, optional) - default ascending sort order, can set to descending with 'desc'

col_attr sort options

  • album_name
  • artist_name
  • release_date
  • num_tracks
  • length

GET Specific Album(s)

/albums?ids={album_ids}
This GET request will return an array of albums. The albums are determined by the ids provided, where {album_ids} is a comma separated list of albums.

Parameters

  • album_ids (string, required) - comma separated list of spotify ids

Tracks

The routes below are for getting information regarding Tracks. Ideally the track specific API would be able to do two things:

  1. Provide a List of Arbitrary Tracks
  2. Provide Specific Tracks

GET List of Arbitrary Tracks

/tracks/{page_num}?psize={psize}&sort={col_attr}&order={asc_desc}
This GET request will return an array of tracks with their information. The use case would be to generate enough tracks to display on the Tracks tab's table for at least one page.

Parameters

  • page_num (number, required) - used as an offset to query by page
  • psize (number, optional) - used to specify the size of the list
  • col_attr (string, optional) - takes a specific column to sort the list of tracks by
  • asc_desc (string, optional) - default ascending sort order, can set to descending with 'desc'

col_attr sort options

  • track_title
  • artist_name
  • release_date
  • album_name
  • duration

GET Specific Track(s)

/tracks?ids={track_ids}
This GET request will return an array of tracks. The tracks are determined by the ids provided, where {track_ids} is a comma separated list of tracks.

Parameters

  • track_ids (string, required) - comma separated list of spotify ids

Static Content

DEPRECATED
For Part 1 static content was required since the back-end and database were not yet required.

Each request is a simple GET that will respond with exact content for specific (hard-coded) id's from Spotify. This means that while this content is "static" it will reflect up to date information from Spotify's servers regarding the specific content with each new request. These specific routes are used for the lists used in the Artists, Albums and Tracks tabs.

For Part 2 and beyond the routes have been updated to take a page number. The page number is an offset of the database.

GET Artists from Spotify

/get_artists DEPRECATED
This GET requests three specific artists from Spotify's Web API to use for Part 1's static content requirement. The Artists are:

  • Chet Faker - 2Q0MyH5YMI5HPQjFjlq5g3
  • Atlas Bound - 6107PIkQDuEUcdpZqSzQsu
  • Jack Ü - 1HxJeLhIuegM3KgvPn8sTa

REPLACED BY /get_artists/{page_num} FOR STATIC CONTENT (TOP 20 ITEMS FROM DATABASE BASED ON PAGE)

GET Albums from Spotify

/get_albums DEPRECATED
This GET requests three specific albums from Spotify's Web API to use for Part 1's static content requirement. The Albums are:

  • 1998 Melbourne Edition - 11wzEOXFI1wgBHxKcsbacJ
  • Lullaby - 3vNsiDEAnZRleKelEgdet1
  • Skrillex and Diplo present Jack Ü - 6bfkwBrGYKJFk6Z4QVyjxd

REPLACED BY /get_albums/{page_num} FOR STATIC CONTENT (TOP 20 ITEMS FROM DATABASE BASED ON PAGE)

GET Tracks from Spotify

/get_tracks DEPRECATED
This GET requests three specific tracks from Spotify's Web API to use for Part 1's static content requirement. The Tracks are:

  • Drop the Game - 4KtrE35pTuqwNc22QP58RT
  • Landed on Mars - 6SXRLE3kFht3wi0glxDueW
  • Where are Ü Now (with Justin Bieber) - 66hayvUbTotekKU3H4ta1f

REPLACED BY /get_tracks/{page_num} FOR STATIC CONTENT (TOP 20 ITEMS FROM DATABASE BASED ON PAGE)

⚠️ **GitHub.com Fallback** ⚠️