From 1cd464b9bc1ac1959cb2b8f75727bf22ad5be4b5 Mon Sep 17 00:00:00 2001 From: Zechariah Tan Date: Tue, 29 Mar 2022 17:00:52 +0800 Subject: [PATCH] Added usage.md and wrote getSearchSuggestions --- README.md | 18 --------------- docs/.vuepress/config.ts | 4 ++++ docs/docs/references.md | 18 +++++++++++++++ docs/docs/usage.md | 49 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 docs/docs/usage.md diff --git a/README.md b/README.md index f5131e8..74a7ccb 100644 --- a/README.md +++ b/README.md @@ -21,24 +21,6 @@ Because of this, I decided to build my own version of a youtube music api with T - Albums - Playlists -### Methods to fetch data - -#### `getSearchSuggestions` - -This function takes in the following parameters - -| Name | Data Type | Description | -| :---- | :-------- | :------------------------------------ | -| query | `string` | Search query you want suggestions for | - -The function returns a `Promise` which are the suggestion results - -```ts -ytmusic.getSearchSuggestions("Lilac").then(res => { - console.log(res) -}) -``` - #### `search` This function takes in the following parameters diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts index fec5ac9..fdb81b9 100644 --- a/docs/.vuepress/config.ts +++ b/docs/.vuepress/config.ts @@ -19,6 +19,10 @@ export default defineUserConfig({ text: "Getting Started", link: "/docs/getting-started.html" }, + { + text: "Usage", + link: "/docs/usage.html" + }, { text: "References", link: "/docs/references.html" diff --git a/docs/docs/references.md b/docs/docs/references.md index fa91f44..291080e 100644 --- a/docs/docs/references.md +++ b/docs/docs/references.md @@ -4,6 +4,24 @@ ### `getSearchSuggestions` +::: tip Properties + +| Name | Data Type | Description | +| :------ | :-------- | :------------------------------------ | +| `query` | `string` | Search query you want suggestions for | + +::: + +::: tip Returns + +`Promise` + +::: + +```ts +public async getSearchSuggestions(query: string): Promise +``` + ### `search` ### `getSong` diff --git a/docs/docs/usage.md b/docs/docs/usage.md new file mode 100644 index 0000000..07808b7 --- /dev/null +++ b/docs/docs/usage.md @@ -0,0 +1,49 @@ +# Usage + +YTMusic provides you many ways of fetching data from YouTube Music
+To leverage all the functions, we will need to create an instance of the class `YTMusic`. +Then, call the `initialize()` to initialize the API before using the API anywhere + +```ts +const ytmusic = new YTMusic() +ytmusic.initialize().then(() => { + // Use API here +}) +``` + +## `getSearchSuggestions` function + +`getSearchSuggestions()` will fetch you a list of search suggestions based on the query + +```ts +ytmusic.getSearchSuggestions("Lilac").then(res => { + console.log(res) +}) +// > [ +// > "lilac", +// > "lilac iu", +// > "lilac band", +// > "lilac wine", +// > "lilac wine miley cyrus", +// > "lilac close my eyes forever", +// > "lilac holy diver" +// > ] +``` + +## `search` function + +## `getSong` function + +## `getVideo` function + +## `getArtist` function + +## `getArtistVideo` function + +## `getArtistAlbums` function + +## `getAlbum` function + +## `getPlaylist` function + +## `getPlaylistVideos` function