@ekwoka/spotify-api
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -10,2 +10,4 @@ export { albumIsSaved } from './albums/albumIsSaved'; | ||
export { saveAlbums } from './albums/saveAlbums'; | ||
export { search } from './search/search'; | ||
export { searchString } from './search/searchString'; | ||
export { getCurrentUser } from './users/getCurrentUser'; | ||
@@ -18,3 +20,4 @@ export { getTopItems } from './users/getTopItems'; | ||
export type { Artist, ArtistStub } from './artists/types'; | ||
export type { QueryType, PageType, SearchResults } from './search/types'; | ||
export type { Track, TrackStub } from './tracks/types'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -10,4 +10,6 @@ export { albumIsSaved } from './albums/albumIsSaved'; | ||
export { saveAlbums } from './albums/saveAlbums'; | ||
export { search } from './search/search'; | ||
export { searchString } from './search/searchString'; | ||
export { getCurrentUser } from './users/getCurrentUser'; | ||
export { getTopItems } from './users/getTopItems'; | ||
export { getUserProfile } from './users/getUserProfile'; |
export { fetchOptions, makeAuthURL, refreshToken, tokensFromCode, } from './auth'; | ||
export { resetCache } from './core/resetCache'; | ||
export { setToken } from './core/setToken'; | ||
export { spotifyApiClient } from './core/spotifyApiClient'; | ||
export { getCurrentUser, getTopItems, getUserProfile, getAlbum, getAlbums, getAlbumTracks, getSavedAlbums, albumIsSaved, saveAlbums, removeAlbums, newReleases, } from './endpoints'; | ||
export { resetCache, setToken, spotifyApiClient } from './core'; | ||
export { albumIsSaved, getAlbum, getAlbums, getAlbumTracks, getCurrentUser, getSavedAlbums, getTopItems, getUserProfile, newReleases, removeAlbums, saveAlbums, search, } from './endpoints'; | ||
export { spotifyFetch } from './utils/spotifyFetch'; | ||
export type { RefreshedToken } from './auth'; | ||
export type { SpotifyTokens } from './auth'; | ||
export type { RefreshedToken, SpotifyTokens } from './auth'; | ||
export type { PersistentApiProperties, SpotifyApiClient, QueryFunction, } from './core/types'; | ||
@@ -10,0 +7,0 @@ export type { Artist, ArtistStub, Track, AlbumStub } from './endpoints'; |
export { fetchOptions, makeAuthURL, refreshToken, tokensFromCode, } from './auth'; | ||
export { resetCache } from './core/resetCache'; | ||
export { setToken } from './core/setToken'; | ||
export { spotifyApiClient } from './core/spotifyApiClient'; | ||
export { getCurrentUser, getTopItems, getUserProfile, getAlbum, getAlbums, getAlbumTracks, getSavedAlbums, albumIsSaved, saveAlbums, removeAlbums, newReleases, } from './endpoints'; | ||
export { resetCache, setToken, spotifyApiClient } from './core'; | ||
export { albumIsSaved, getAlbum, getAlbums, getAlbumTracks, getCurrentUser, getSavedAlbums, getTopItems, getUserProfile, newReleases, removeAlbums, saveAlbums, search, } from './endpoints'; | ||
export { spotifyFetch } from './utils/spotifyFetch'; |
@@ -12,3 +12,3 @@ { | ||
"license": "MIT", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Composable Wrapper for the Spotify Web Api and Spotify Web Playback SDK", | ||
@@ -25,7 +25,7 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/node": "^18.7.5", | ||
"@types/node": "^18.7.8", | ||
"@typescript-eslint/eslint-plugin": "^5.33.1", | ||
"@typescript-eslint/parser": "^5.33.1", | ||
"c8": "^7.12.0", | ||
"esbuild": "^0.15.3", | ||
"@vitest/coverage-c8": "^0.22.1", | ||
"esbuild": "^0.15.5", | ||
"eslint": "^8.22.0", | ||
@@ -38,5 +38,5 @@ "gzip-size": "^7.0.0", | ||
"typescript": "^4.7.4", | ||
"undici": "^5.8.2", | ||
"vite": "^3.0.8", | ||
"vitest": "^0.22.0" | ||
"undici": "^5.9.1", | ||
"vite": "^3.0.9", | ||
"vitest": "^0.22.1" | ||
}, | ||
@@ -52,3 +52,3 @@ "prettier": { | ||
"lint": "eslint --fix ./src; prettier --write ./src --loglevel error", | ||
"lint:check": "eslint --max-warnings 0 ./src && prettier --check ./src", | ||
"lint:check": "eslint --max-warnings 10 ./src && prettier --check ./src", | ||
"prebuild": "rm -rf dist", | ||
@@ -55,0 +55,0 @@ "patch": "run-s test:run build && pnpm version patch && pnpm publish", |
@@ -7,2 +7,3 @@ # ⚡️A tree-shakable, composable, lightweight wrapper for the multiple Spotify APIs🔥 | ||
[<img src="https://img.shields.io/bundlephobia/minzip/@ekwoka/spotify-api?style=for-the-badge">](https://bundlephobia.com/package/@ekwoka/spotify-api) | ||
<img src="https://img.shields.io/badge/coverage-99%25-success?style=for-the-badge&logo=testCafe&logoColor=white" alt="99% test coverage"> | ||
@@ -234,2 +235,79 @@ Born from my own difficulties using other wrapper libraries for Spotify, this library seeks to be the best possible API wrapper. | ||
### Search | ||
There is only one Search endpoint: | ||
- `search` | ||
Included is also a utility function for building more advanced query string. | ||
#### search | ||
This endpoint performs a query search of various Spotify data types and returns data on all of them. | ||
```js | ||
// Single Search Type | ||
const results = client(search('pink venom', 'track')) | ||
// Multiple Search Types | ||
const results = client(search('pink venom', ['track', 'album'])) | ||
// With additional options | ||
const results = client(search('pink venom', 'track', { | ||
limit: 50, | ||
offset: 0, | ||
market: 'KR', | ||
include_external: 'audio' | ||
})) | ||
``` | ||
- Arguments: | ||
1. query: `string` *required* | ||
2. type: `string | string[]` *required* | ||
- `track` | ||
- `album` | ||
- `artist` | ||
- `playlist` | ||
- `track` | ||
- `show` | ||
- `episode` | ||
3. Options: `object` | ||
- `limit`: The number of items to return. Default: `20`. Maximum: `50`. | ||
- `offset`: The index of the first item to return. Default: `0`. | ||
- `market`: String representation of market. | ||
- `include_external`: Allows including references to playable content from outside Spotify. This defaults to nothing, and must be set to `audio` to include those references. | ||
While other endpoints mostly have pretty concrete return types, this endpoint returns an object with keys that are the provided `type` strings with an `s` appended. | ||
Example: | ||
```js | ||
client(search('pink venom', 'track')) | ||
// { tracks: {...} } | ||
client(search('pink venom', ['track', 'album'])) | ||
// { | ||
// tracks: {...}, | ||
// albums: {...} | ||
// } | ||
``` | ||
#### searchString helper | ||
The provided `searchString` function accepts and object and can easily create more advanced search queries to filter results | ||
```js | ||
import { searchString } from '@ekwoka/spotify-api/endpoints/search' | ||
const query = searchString({ | ||
q: 'pink venom', // string | ||
artist: 'blackpink', // string: filters for provided artist | ||
album: 'pink venom', // string: filters for provided album | ||
year: 2022, // number | string: filters for provided year | ||
genre: 'pop', // string: filters for provided genre | ||
tag: 'hipster', // 'hipster' | 'new': filters for low popularity or recent releases | ||
}); | ||
const results = client(search(searchString())) | ||
``` | ||
For more information on all the options here, check the [official Spotify docs for the Search endpoint](https://developer.spotify.com/documentation/web-api/reference/#/operations/search) | ||
### Users | ||
@@ -236,0 +314,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77853
146
1051
413