A simple chart API written in Flask for Melon, a Korean music streaming service.
Fetch Melon charts.
URL : /api/v1/chart/:time
URL Parameters : time=[string]
where time
is the specific chart you want. Available charts:
- live
rise(depercated)- day
- week
- month
Method : GET
Condition : User receives chart in json
format. Response contains 100 entries. Key is ranking of song; value is name, ranking, artists, songId, albumId (id's are Melon specific).
Code : 200 OK
Eample Content :
{"1": {"name": "์์(Prod.&Feat. SUGA of BTS)", "ranking": "1", "artists": "์์ด์ ", "songId": "32578498", "albumId": "10426648"}, "2": {"name": "๋๋น์ ๊ณ ์์ด (feat.๋ฐฑํ (BAEKHYUN))", "ranking": "2", "artists": "๋ณผ๋นจ๊ฐ์ฌ์ถ๊ธฐ", "songId": "32583036", "albumId": "10427559"}, "3": {"name": "ON", "ranking": "3", "artists": "๋ฐฉํ์๋
๋จ", "songId": "32399830", "albumId": "10377346"}, "4": {"name": "์๋กํ", "ranking": "4", "artists": "์กฐ์ ์", "songId": "32491274", "albumId": "10409054"}, "5": {"name": "์ด์ง ์ค๋ ์ด (Nonstop)", "ranking": "5", "artists": "์ค๋ง์ด๊ฑธ", "songId": "32559781", "albumId": "10423289"}, "6": {"name": "00:00 (Zero OโClock)", "ranking": "6", "artists": "๋ฐฉํ์๋
๋จ", "songId": "32399832", "albumId": "10377346"}, "7": {"name": "Black Swan", "ranking": "7", "artists": "๋ฐฉํ์๋
๋จ", "songId": "32323969", "albumId": "10377346"}, "8": {"name": "์์ ๊ฒ๋ค์ ์ํ ์ (Boy With Luv) (Feat. Halsey)", "ranking": "8", "artists": "๋ฐฉํ์๋
๋จ", "songId": "31737197", "albumId": "10273641"}, "9": {"name": "์น๊ตฌ", "ranking": "9", "artists": "๋ฐฉํ์๋
๋จ", "songId": "32399834", "albumId": "10377346"}, "10": {"name": "Filter", "ranking": "10", "artists": "๋ฐฉํ์๋
๋จ", "songId": "32399827", "albumId": "10377346"}, "11": {"name": "์์ฐจ", "ranking": "11", "artists": "๋ฐฉํ์๋
๋จ", "songId": "32399828", "albumId": "10377346"}, "12": {"name": "Moon", "ranking": "12", "artists": "๋ฐฉํ์๋
๋จ", "songId": "32399835", "albumId": "10377346"}, "13": {"name": "Inner Child", "ranking": "13", "artists": "๋ฐฉํ์๋
๋จ", "songId": "32399833", "albumId": "10377346"}, "14": {"name": "We are Bulletproof : the Eternal", "ranking": "14", "artists": "๋ฐฉํ์๋
๋จ", "songId": "32399837", "albumId": "10377346"}, "15": {"name": "Louder than bombs", "ranking": "15", "artists": "๋ฐฉํ์๋
๋จ", "songId": "32399829", "albumId": "10377346"}, "16": {"name": "์ฑ (UGH!)", "ranking": "16", "artists": "๋ฐฉํ์๋
๋จ", "songId": "32399831", "albumId": "10377346"}, "17": {"name": "Interlude : Shadow", "ranking": "17", "artists": "๋ฐฉํ์๋
๋จ", "songId": "32399826", "albumId": "10377346"}, "18": {"name": "Respect", "ranking": "18", "artists": "๋ฐฉํ์๋
๋จ", "songId": "32399836", "albumId": "10377346"}, "19": {"name": "Outro : Ego", "ranking": "19", "artists": "๋ฐฉํ์๋
๋จ", "songId": "32399838", "albumId": "10377346"}, "20": {"name": "Ridinโ", "ranking": "20", "artists": "NCT DREAM", "songId": "32550660", "albumId": "10421298"}, "21": {"name": "Yours (Feat. ์ดํ์ด, ์ฐฝ๋ชจ)", "ranking": "21", "artists": "Raiden, ์ฐฌ์ด (CHANYEOL)", "songId": "32590490", "albumId": "10429159"}, "22": {"name": "Zombie", "ranking": "22", "artists": "DAY6 (๋ฐ์ด์์ค)", "songId": "32586848", "albumId": "10428497"}, "23": {"name": "๋๋ฅผ ์ฌ๋ํ๊ณ ์์ด", "ranking": "23", "artists": "๋ฐฑํ (BAEKHYUN)", "songId": "32298623", "albumId": "10372655"}, "24": {"name": "์ฒ์์ฒ๋ผ", "ranking": "24", "artists": "์ ์จ๋๋งฅ์ค (M.C the MAX)", "songId": "32486613", "albumId": "10408131"}, "25": {"name": "๋ด๊ฒ ๋งํด์ค (7 Days)", "ranking": "25", "artists": "NCT DREAM", "songId": "32550662", "albumId": "10421298"}, "26": {"name": "์์", "ranking": "26", "artists": "๊ฐํธ (Gaho)", "songId": "32345931", "albumId": "10381712"}, "27": {"name": "๋์ ์๋ฆฌ (Puzzle Piece)", "ranking": "27", "artists": "NCT DREAM", "songId": "32550664", "albumId": "10421298"}, "28": {"name": "์ฌ๋, ํ์", "ranking": "28", "artists": "์ํธ (SUHO)", "songId": "32495729", "albumId": "10409970"}, "29": {"name": "์ฌ๋์ ๋๋ค์ (Love Again)", "ranking": "29", "artists": "NCT DREAM", "songId": "32550663", "albumId": "10421298"}, "30": {"name": "๋ค๋๋ผ(Dumhdurum)", "ranking": "30", "artists": "Apink (์์ดํํฌ)", "songId": "32528369", "albumId": "10416723"}, "31": {"name": "Quiet Down", "ranking": "31", "artists": "NCT DREAM", "songId": "32550661", "albumId": "10421298"}, "32": {"name": "Happy", "ranking": "32", "artists": "ํ์ฐ (TAEYEON)", "songId": "32572926", "albumId": "10425647"}, "33": {"name": "Dolphin", "ranking": "33", "artists": "์ค๋ง์ด๊ฑธ", "songId": "32559782", "albumId": "10423289"}, "34": {"name": "์ข์ ์ฌ๋ ์์ผ๋ฉด ์๊ฐ์์ผ์ค", "ranking": "34", "artists": "์กฐ์ด (JOY)", "songId": "32473998", "albumId": "10405712"}, "35": {"name": "์ด์ ๋๋ง ๋ฏฟ์ด์", "ranking": "35", "artists": "์์์
", "songId": "32508053", "albumId": "10412319"}, "36": {"name": "๋์๊ฒ ๊ฐ๋ ์ด ๊ธธ ์์์ (๋.์ด.๊ธธ)", "ranking": "36", "artists": "๋ฐฑํ (BAEKHYUN)", "songId": "32421335", "albumId": "10396078"}, "37": {"name": "Obsession", "ranking": "37", "artists": "EXO", "songId": "32217921", "albumId": "10357878"}, "38": {"name": "Blueming", "ranking": "38", "artists": "์์ด์ ", "songId": "32183386", "albumId": "10346650"}, "39": {"name": "METEOR", "ranking": "39", "artists": "์ฐฝ๋ชจ (CHANGMO)", "songId": "32224272", "albumId": "10359162"}, "40": {"name": "ํ๋ค๋ฆฌ๋ ๊ฝ๋ค ์์์ ๋ค ์ดํธํฅ์ด ๋๊ปด์ง๊ฑฐ์ผ", "ranking": "40", "artists": "์ฅ๋ฒ์ค", "songId": "32003395", "albumId": "10320500"}, "41": {"name": "Love me or Leave me", "ranking": "41", "artists": "DAY6 (๋ฐ์ด์์ค)", "songId": "32586850", "albumId": "10428497"}, "42": {"name": "์์
(่ฑ้; Kick It)", "ranking": "42", "artists": "NCT 127", "songId": "32393669", "albumId": "10391380"}, "43": {"name": "Go away go away", "ranking": "43", "artists": "์ฐฌ์ด (CHANYEOL), ํ์น (Punch)", "songId": "32325829", "albumId": "10377809"}, "44": {"name": "์๋ฌด๋
ธ๋", "ranking": "44", "artists": "์ง์ฝ (ZICO)", "songId": "32313543", "albumId": "10375118"}, "45": {"name": "Dance Monkey", "ranking": "45", "artists": "Tones And I", "songId": "31979846", "albumId": "10316394"}, "46": {"name": "๋ง์์ ๋๋ ค์", "ranking": "46", "artists": "์์ด์ ", "songId": "32378104", "albumId": "10388744"}, "47": {"name": "๊ทธ๋ ๊ทธ ์์ธ", "ranking": "47", "artists": "๊นํ", "songId": "32377231", "albumId": "10388581"}, "48": {"name": "Made In You", "ranking": "48", "artists": "์ํธ (SUHO)", "songId": "32495730", "albumId": "10409970"}, "49": {"name": "์ด๋ 60๋ ๋
ธ๋ถ๋ถ์ด์ผ๊ธฐ", "ranking": "49", "artists": "์์์
", "songId": "32397381", "albumId": "10391899"}, "50": {"name": "์ฐ๋ฆฌ ๋ง๋จ์ด", "ranking": "50", "artists": "ํดํด", "songId": "32550314", "albumId": "10421264"}, "51": {"name": "ํด์ ๋ฌ์ฒ๋ผ", "ranking": "51", "artists": "DAY6 (๋ฐ์ด์์ค)", "songId": "32586847", "albumId": "10428497"}, "52": {"name": "๋๋ฉ์ด", "ranking": "52", "artists": "ํํ์ฐ (๊ตญ์นด์คํ
)", "songId": "32361098", "albumId": "10385262"}, "53": {"name": "์ํ์", "ranking": "53", "artists": "์ํธ (SUHO)", "songId": "32495732", "albumId": "10409970"}, "54": {"name": "Iโm in Trouble", "ranking": "54", "artists": "๋ด์ด์คํธ", "songId": "32588064", "albumId": "10428727"}, "55": {"name": "Oโ", "ranking": "55", "artists": "์ํธ (SUHO)", "songId": "32495728", "albumId": "10409970"}, "56": {"name": "๋์ ์ฐจ๋ก (Feat. ์คํ)", "ranking": "56", "artists": "์ํธ (SUHO)", "songId": "32495733", "albumId": "10409970"}, "57": {"name": "ํ๋ คํ์ง ์์ ๊ณ ๋ฐฑ", "ranking": "57", "artists": "๊ทํ (KYUHYUN)", "songId": "32508146", "albumId": "10412335"}, "58": {"name": "์๋ง ์ปคํผ", "ranking": "58", "artists": "์ํธ (SUHO)", "songId": "32495731", "albumId": "10409970"}, "59": {"name": "๋ฐ๋จ", "ranking": "59", "artists": "์์์
", "songId": "32323330", "albumId": "10377157"}, "60": {"name": "์ด๋ป๊ฒ ์ง๋ด (Prod. By VAN.C)", "ranking": "60", "artists": "์ค๋ฐ", "songId": "32438894", "albumId": "10399190"}, "61": {"name": "WANNABE", "ranking": "61", "artists": "ITZY (์์ง)", "songId": "32445339", "albumId": "10400522"}, "62": {"name": "Tick Tock", "ranking": "62", "artists": "DAY6 (๋ฐ์ด์์ค)", "songId": "32586849", "albumId": "10428497"}, "63": {"name": "๋ฐ๋ง", "ranking": "63", "artists": "์ง๋ฏผํธ", "songId": "32224409", "albumId": "10359204"}, "64": {"name": "Memories", "ranking": "64", "artists": "Maroon 5", "songId": "32055419", "albumId": "10330593"}, "65": {"name": "Psycho", "ranking": "65", "artists": "Red Velvet (๋ ๋๋ฒจ๋ฒณ)", "songId": "32273582", "albumId": "10368053"}, "66": {"name": "ํ", "ranking": "66", "artists": "๋ณผ๋นจ๊ฐ์ฌ์ถ๊ธฐ", "songId": "32594046", "albumId": "10427559"}, "67": {"name": "๋ฆ์ ๋ฐค ๋์ ์ง ์ ๊ณจ๋ชฉ๊ธธ์์", "ranking": "67", "artists": "๋
ธ์", "songId": "32156286", "albumId": "10348811"}, "68": {"name": "Afraid", "ranking": "68", "artists": "DAY6 (๋ฐ์ด์์ค)", "songId": "32586853", "albumId": "10428497"}, "69": {"name": "๋์ ํ๋ฃจ๋ ๋ค ๋๋ก ๊ฐ๋ํด", "ranking": "69", "artists": "์ง์ฝ (ZICO), ์ฌ๋ (WENDY)", "songId": "32600237", "albumId": "10431009"}, "70": {"name": "๋ณด๋ผ๋น ์ฝ์", "ranking": "70", "artists": "์์์
", "songId": "32441451", "albumId": "10399605"}, "71": {"name": "Don't Start Now", "ranking": "71", "artists": "Dua Lipa", "songId": "32137576", "albumId": "10345880"}, "72": {"name": "FIESTA", "ranking": "72", "artists": "IZ*ONE (์์ด์ฆ์)", "songId": "32381408", "albumId": "10389281"}, "73": {"name": "1 to 10", "ranking": "73", "artists": "DAY6 (๋ฐ์ด์์ค)", "songId": "32586852", "albumId": "10428497"}, "74": {"name": "๋ด ๋๋ฌผ ๋ชจ์", "ranking": "74", "artists": "ํ์ธ (Whee In)", "songId": "32561690", "albumId": "10423707"}, "75": {"name": "๋ด๋ ", "ranking": "75", "artists": "๋ฐฉํ์๋
๋จ", "songId": "30244931", "albumId": "10037969"}, "76": {"name": "๊ทธ๋ ๊ณ ์ด ๋ด์ฌ๋", "ranking": "76", "artists": "์ด๋ฐ์์นดํ", "songId": "32521396", "albumId": "10415229"}, "77": {"name": "์ค๋๋ ๋น๋๋ ๋์๊ฒ (To You My Light) (Feat.์ด๋ผ์จ)", "ranking": "77", "artists": "๋งํฌํฝ (MAKTUB)", "songId": "31853557", "albumId": "10294603"}, "78": {"name": "2002", "ranking": "78", "artists": "Anne-Marie", "songId": "31029291", "albumId": "10137250"}, "79": {"name": "๋๋ ค์ณ", "ranking": "79", "artists": "DAY6 (๋ฐ์ด์์ค)", "songId": "32586851", "albumId": "10428497"}, "80": {"name": "๋๋ณด๋ค ๋ ์ฌ๋ํด์", "ranking": "80", "artists": "๊นํธ์ค", "songId": "32560653", "albumId": "10423519"}, "81": {"name": "์ฐ๋ฆฌ ์ ํค์ด์ ธ์ผ ํด", "ranking": "81", "artists": "์ ์์", "songId": "32187544", "albumId": "10353881"}, "82": {"name": "Love poem", "ranking": "82", "artists": "์์ด์ ", "songId": "32143487", "albumId": "10346650"}, "83": {"name": "Stay Tonight", "ranking": "83", "artists": "์ฒญํ", "songId": "32559498", "albumId": "10423202"}, "84": {"name": "๋๋ฅผ ๊ทธ๋ฆฐ ์ฐ์ฃผ (Insomnia2020) (Feat. ์ด๋ผ์จ)", "ranking": "84", "artists": "๋งํฌํฝ (MAKTUB)", "songId": "32556676", "albumId": "10422586"}, "85": {"name": "Moon Dance", "ranking": "85", "artists": "๋ด์ด์คํธ", "songId": "32588063", "albumId": "10428727"}, "86": {"name": "Stuck with U", "ranking": "86", "artists": "Ariana Grande, Justin Bieber", "songId": "32584913", "albumId": "10428037"}, "87": {"name": "๋ ๋ด๊ฐ ๋ณด๊ณ ์ถ์ง ์๋ ๋ด", "ranking": "87", "artists": "์ ์์", "songId": "32559566", "albumId": "10423244"}, "88": {"name": "Back To Me (ํํ์ฐ์ฃผ)", "ranking": "88", "artists": "๋ด์ด์คํธ", "songId": "32588066", "albumId": "10428727"}, "89": {"name": "๋ชจ๋ ๋ , ๋ชจ๋ ์๊ฐ (Every day, Every Moment)", "ranking": "89", "artists": "ํดํด", "songId": "30962526", "albumId": "10149492"}, "90": {"name": "๊ผญ", "ranking": "90", "artists": "๋ด์ด์คํธ", "songId": "32588067", "albumId": "10428727"}, "91": {"name": "์ผํธ๋จ์ฌ ๋ฏผ๋ค๋ ์ผ", "ranking": "91", "artists": "์์์
", "songId": "32362652", "albumId": "10385603"}, "92": {"name": "Firework", "ranking": "92", "artists": "๋ด์ด์คํธ", "songId": "32588065", "albumId": "10428727"}, "93": {"name": "์ด๋ป๊ฒ ์ด๋ณ๊น์ง ์ฌ๋ํ๊ฒ ์ด, ๋ ์ฌ๋ํ๋ ๊ฑฐ์ง", "ranking": "93", "artists": "AKMU (์
๋๋ฎค์ง์
)", "songId": "32061975", "albumId": "10331947"}, "94": {"name": "Maniac", "ranking": "94", "artists": "Conan Gray", "songId": "32122539", "albumId": "10343276"}, "95": {"name": "๋ฐ๋ง๋ณ", "ranking": "95", "artists": "๋ด์ด์คํธ", "songId": "32588068", "albumId": "10428727"}, "96": {"name": "์์ฌํ", "ranking": "96", "artists": "์์์
", "songId": "32555799", "albumId": "10422374"}, "97": {"name": "๋ฐฐ์ ์", "ranking": "97", "artists": "์์์
", "songId": "32457760", "albumId": "10402513"}, "98": {"name": "Zombie (English Ver.)", "ranking": "98", "artists": "DAY6 (๋ฐ์ด์์ค)", "songId": "32586854", "albumId": "10428497"}, "99": {"name": "LALALILALA", "ranking": "99", "artists": "์์ดํ๋ฆด (APRIL)", "songId": "32550258", "albumId": "10421256"}, "100": {"name": "๋ ์ฃผ๋จน", "ranking": "100", "artists": "์์์
", "songId": "32457753", "albumId": "10402513"}}
cURL : curl 'https://<endpoint>/api/v1/chart/live'
fetch :
fetch('https://<endpoint>/api/v1/chart/live')
.then(res => res.json())
.then(console.log)
Fetch lyrics from Melon.
URL : /api/v1/lyric/:songId
URL Parameters : songId=[int]
where songId
is the Melon specific id of a song.
Method : GET
Condition : User receives lyric in json
format. Key is lyric
and value is the lyric of the song.
Code : 200 OK
Eample Content :
{
"lyric": "์ด ๋ฐค ๊ทธ๋ ์ ๋ฐ๋ง๋ถ์\n๋น์ ์ ์ฐฝ ๊ฐ๊น์ด ๋ณด๋ผ๊ฒ์\n์ ์ฌ๋ํ๋ค๋ ๋ง์ด์์\n๋ ์ฐ๋ฆฌ์ ์ฒซ ์
๋ง์ถค์ ๋ ์ฌ๋ ค\n๊ทธ๋ผ ์ธ์ ๋ ๋์ ๊ฐ๊ณ \n์ ๊ฐ์ฅ ๋จผ ๊ณณ์ผ๋ก ๊ฐ์\n๋ ํ๋๊ฐ ๋จธ๋ฌผ๋\n๋ชจ๋ ์์ ์ ํ ๊ธ์จ์ฒ๋ผ\n๊ทธ๋๊ฐ ๋ฉ๋ฆฌ ์ฌ๋ผ์ ธ ๋ฒ๋ฆด ๊ฒ ๊ฐ์\n๋ ๊ทธ๋ฆฌ์ ๊ทธ๋ฆฌ์\n์ฌ๊ธฐ ๋ด ๋ง์์์\n๋ชจ๋ ๋ง์ ๋ค ๊บผ๋ด์ด ์ค ์ ์์ง๋ง\n์ฌ๋ํ๋ค๋ ๋ง์ด์์\n์ด๋ป๊ฒ ๋์๊ฒ\n๊ทธ๋๋ ํ์ด์ด ์จ ๊ฑธ๊น\n์ง๊ธ ์ฐ๋ฆฌ ํจ๊ป ์๋ค๋ฉด ์\n์ผ๋ง๋ ์ข์๊น์\n๋ ํ๋๊ฐ ๋จธ๋ฌผ๋\n๋ชจ๋ ์์ ์ ํ ๊ธ์จ์ฒ๋ผ\n๊ทธ๋๊ฐ ๋ฉ๋ฆฌ ์ฌ๋ผ์ ธ ๋ฒ๋ฆด ๊ฒ ๊ฐ์\n๋ ๊ทธ๋ฆฌ์ ๋ ๊ทธ๋ฆฌ์\n๋์ ์ผ๊ธฐ์ฅ ์์\n๋ชจ๋ ๋ง์ ๋ค ๊บผ๋ด์ด ์ค ์ ์์ง๋ง\n์ฌ๋ํ๋ค๋ ๋ง\n์ด ๋ฐค ๊ทธ๋ ์ ๋ฐ๋ง๋ถ์ ๋น์ ์\n์ฐฝ ๊ฐ๊น์ด ๋์ธ๊ฒ์\n์ ์ข์ ๊ฟ ์ด๊ธธ ๋ฐ๋ผ์"
}
cURL : curl 'https://<endpoint>/api/v1/lyric/30314784'
fetch :
fetch('https://<endpoint>/api/v1/lyric/30314784')
.then(res => res.json())
.then(console.log)
melon-api can be installed from pypi
pip install melonapi
Printing out the top 100 songs right now on Melon.
from melonapi import scrapeMelon
print(scrapeMelon.getList("LIVE").decode())
Virtualenv is a handy way to manage different Python projects.
- Install virtualenv via
pip3 install virtualenv
- Create a virtual environment via
virtualenv venv
- Activate virtual environment via
source venv/bin/activate
- Install dependencies via
pip install -r requirements.txt
Run the following command inside the melonapi
directory to serve up flask web app.
FLASK_ENV=development flask run --port 5000
Navigate to localhost:5000
to access the app.
Add this to your .bashrc or run it in your shell or add it your server env vars if you want the Spotify playlist feature.
https://developer.spotify.com/
export client_id='yourClientID'
export client_secret='yourClientSecret'
You can obtain the image via Dockerhub or build from source
docker pull danielko8/melonapi:latest
docker build -t melon-api:latest .
docker run -p 5000:5000 melon-api
Now go to localhost:5000
to access the api!
- Search (by name, genre, etc)
- Playlist creation, list of song id's and create a new playlist (reverse engineering)
- List most popular songs of a given artist
- Visualize data
- Download lyric support
- Top 100 songs => Spotify Playlist conversion (nontrival task as spotify search is not very good for korean input, apple music search is really good but their api rate limited me so i tried tor but seemed like abuse)
- Caching results (https://hackernoon.com/a-cache-is-fast-enhancing-our-api-with-redis-bd61d13c3ca8 and http://ghibliapi.herokuapp.com/#section/Helper-Libraries)
- Refractor scrapeMelon to remove subprocess, this will not work on windows machines which do not have cURL
- Auto push to pip using github actions