This Git repository contains the files needed for testing the MusixMatch RestAPI wrapper, and guidlines on how to test it.
The solution was built with PowerShell.
Important notice - The assignment requests the song to be included in an album (not a single or EP).
Even though i saw that MusixMatch published an endpoint that allows to request the type of the album of a song,
I did not know how to search for a word in a lyrics of a song and filter for the album type.
The script is APIScripts\APIConsumer.ps1, and it has 3 function defined:
RestApiInvoker
a helper function that is in charge of building the URI string for querying, and running it againts the MusixMatch API.
it accepts 4 paramaters:
endpoint - the URL of the API
query - the query that should be passed to the endpoint
key - key used to authenticate
method - REST method to be used (it is GET by default, if we want to build upon it in the future, it can be changed)
ExportResultsCsv
a helper function that exports the data to the CSV.
it accepts 2 paramaters:
Path - Path of the CSV that the data should be exported to
Data - The objects \ data that should be exported to the CSV
Search-MusixMatch
The main function that is being called, the which the user needs to "interact" with.
it accepts 5 paramaters:
ApiURI - the URL of the API, being passed to RestApiInvoker. has a default value of https://api.musixmatch.com/ws/1.1/ (user can use any other URL if specifying a different value)
Lyrics - The word that we want to search in the lyrics of songs.
ApiKey - The API Key that is being used to authenticate with MusixMatch. It has a default value of my API key, that will be deleted in the future. In real world situations, this should never be done
RestApiMode - This paramter shoulbe be used in the second assignment - basically it prevents the script from exporting to CSV
CSVPath - the path of CSV - being passed to ExportResultsCsv. has a default value of (in Windows) C:\users%username%\MusixMatch.csv
First, from a PowerShell promot, CD into the root folder of the git repo:
CD C:\musixmatch
Next, Import the APIConsumer.ps1 script:
Import-Module .\APIScripts\APIConsumer.ps1
if you get an error while importing the script, run the following command:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
Now run the Search-MusixMatch function:
Search-MusixMatch -Lyrics "california dreamin"
If you want to export the CSV to a different path, desktop for example:
Search-MusixMatch -Lyrics "california dreamin" -CSVPath "$env:userprofile\Desktop\MusixMatch.csv"
If you want to show the results in the console, use the RestApiMode switch parameter:
Search-MusixMatch -Lyrics "california dreamin" -RestApiMode
Thhe docker file uses the latest alpine image, copies the Pode PowerShell module, and run the server.ps1 scripts which hosts a REST api server. That REST api server is used to query the MusixMatch api using the Search-MusixMatch function with the -RestApiMode paramter. run http://localhost:8088/ for more information :)