@ekwoka/spotify-api
Advanced tools
Comparing version 0.0.6 to 0.0.7
export { resetCache } from './resetCache'; | ||
export { setToken } from './setToken'; | ||
export { spotifyApiClient } from './spotifyApiClient'; | ||
export type { PersistentApiProperties, SpotifyApiClient, QueryFunction, QueryConstructor, } from './types'; | ||
export type { PersistentApiProperties, SpotifyApiClient, QueryFunction, } from './types'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { QueryConstructor } from './types'; | ||
import { QueryFunction } from './types'; | ||
/** | ||
@@ -9,3 +9,3 @@ * The resetCache utility cleans out the cache on the active client, either | ||
*/ | ||
export declare const resetCache: QueryConstructor; | ||
export declare const resetCache: (cacheType?: string) => QueryFunction; | ||
//# sourceMappingURL=resetCache.d.ts.map |
@@ -1,3 +0,3 @@ | ||
import { QueryConstructor } from './'; | ||
export declare const setToken: QueryConstructor; | ||
import { QueryFunction } from './types'; | ||
export declare const setToken: (newToken: string) => QueryFunction; | ||
//# sourceMappingURL=setToken.d.ts.map |
@@ -8,4 +8,3 @@ export declare type PersistentApiProperties = { | ||
export declare type SpotifyApiClient = <T>(fn: QueryFunction<T>) => T; | ||
export declare type QueryFunction<T> = (props: PersistentApiProperties) => T; | ||
export declare type QueryConstructor<T = void> = (...args: unknown[]) => QueryFunction<T>; | ||
export declare type QueryFunction<T = void> = (props: PersistentApiProperties) => T; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { QueryConstructor } from '../..'; | ||
import { QueryFunction } from '../../core'; | ||
/** | ||
@@ -8,3 +8,3 @@ * Accesses the Spotify /me endpoint to get information regarding the current | ||
*/ | ||
export declare const getCurrentUser: QueryConstructor<Promise<User>>; | ||
export declare const getCurrentUser: () => QueryFunction<Promise<User>>; | ||
declare type User = { | ||
@@ -11,0 +11,0 @@ country: string; |
@@ -0,12 +1,14 @@ | ||
export { fetchOptions } from './auth/fetchOptions'; | ||
export { refreshToken } from './auth/refreshToken'; | ||
export { tokensFromCode } from './auth/tokensFromCode'; | ||
export { SPOTIFY_URL, SPOTIFY_AUTH } from './constants'; | ||
export { resetCache } from './core/resetCache'; | ||
export { setToken } from './core/setToken'; | ||
export { spotifyApiClient } from './core/spotifyApiClient'; | ||
export { getCurrentUser } from './endpoints/users/getCurrentUser'; | ||
export { getCurrentUser, getTopItems, getUserProfile } from './endpoints'; | ||
export { spotifyFetch } from './utils/spotifyFetch'; | ||
export type { RefreshedToken } from './auth/refreshToken'; | ||
export type { SpotifyTokens } from './auth/tokensFromCode'; | ||
export type { PersistentApiProperties, SpotifyApiClient, QueryFunction, QueryConstructor, } from './core/types'; | ||
export type { RefreshedToken } from './auth'; | ||
export type { SpotifyTokens } from './auth'; | ||
export type { PersistentApiProperties, SpotifyApiClient, QueryFunction, } from './core/types'; | ||
export type { Artist, ArtistStub, Track, AlbumStub } from './endpoints'; | ||
export type { Image, SpotifyPageURL, SpotifyAPIURL, } from './utils/SpotifyUtilityTypes'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -0,8 +1,8 @@ | ||
export { fetchOptions } from './auth/fetchOptions'; | ||
export { refreshToken } from './auth/refreshToken'; | ||
export { tokensFromCode } from './auth/tokensFromCode'; | ||
export { SPOTIFY_URL, SPOTIFY_AUTH } from './constants'; | ||
export { resetCache } from './core/resetCache'; | ||
export { setToken } from './core/setToken'; | ||
export { spotifyApiClient } from './core/spotifyApiClient'; | ||
export { getCurrentUser } from './endpoints/users/getCurrentUser'; | ||
export { getCurrentUser, getTopItems, getUserProfile } from './endpoints'; | ||
export { spotifyFetch } from './utils/spotifyFetch'; |
@@ -6,2 +6,4 @@ export { deepFreeze } from './deepFreeze'; | ||
export { toBase64 } from './toBase64'; | ||
export { toURLString } from './toURLString'; | ||
export type { Image, SpotifyPageURL, SpotifyAPIURL, } from './SpotifyUtilityTypes'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -6,1 +6,2 @@ export { deepFreeze } from './deepFreeze'; | ||
export { toBase64 } from './toBase64'; | ||
export { toURLString } from './toURLString'; |
@@ -12,3 +12,3 @@ { | ||
"license": "MIT", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Composable Wrapper for the Spotify Web Api and Spotify Web Playback SDK", | ||
@@ -49,2 +49,3 @@ "keywords": [ | ||
"lint": "eslint --fix ./src; prettier --write ./src --loglevel error", | ||
"lint:check": "eslint --max-warnings 0 ./src && prettier --check ./src", | ||
"prebuild": "rm -rf dist", | ||
@@ -51,0 +52,0 @@ "patch": "run-s test:run build && pnpm version patch && pnpm publish", |
# ⚡️A tree-shakable, composable, lightweight wrapper for the multiple Spotify APIs🔥 | ||
[<img src="https://badgen.net/npm/v/@ekwoka/spotify-api">](https://www.npmjs.com/package/@ekwoka/spotify-api) | ||
<img src="https://badgen.net/npm/types/@ekwoka/spotify-api?icon=typescript"> | ||
<img src="https://badgen.net/npm/dt/@ekwoka/spotify-api" > | ||
[<img src="https://badgen.net/bundlephobia/minzip/@ekwoka/spotify-api">](https://bundlephobia.com/package/@ekwoka/spotify-api) | ||
[<img src="https://img.shields.io/npm/v/@ekwoka/spotify-api?style=for-the-badge">](https://www.npmjs.com/package/@ekwoka/spotify-api) | ||
<img src="https://img.shields.io/npm/types/@ekwoka/spotify-api?label=%20&logo=typescript&logoColor=white&style=for-the-badge"> | ||
<img src="https://img.shields.io/npm/dt/@ekwoka/spotify-api?style=for-the-badge" > | ||
[<img src="https://img.shields.io/bundlephobia/minzip/@ekwoka/spotify-api?style=for-the-badge">](https://bundlephobia.com/package/@ekwoka/spotify-api) | ||
@@ -113,2 +113,4 @@ Born from my own difficulties using other wrapper libraries for Spotify, this library seeks to be the best possible API wrapper. | ||
Gets details of the currently logged in user (identified by token) | ||
```js | ||
@@ -120,2 +122,31 @@ const user = client(getCurrentUser()); | ||
cache key: 'user' | ||
#### getTopItems | ||
Gets the users top tracks or artists | ||
```js | ||
const topTracks = await client( | ||
getTopItems('tracks', { limit: 50, time_range: 'long_term' }) | ||
); | ||
const topArtists = await client( | ||
getTopItems('artists', { offset: 20, limit: 10 }) | ||
); | ||
``` | ||
Options: | ||
- `limit`: The number of items to return. Default: `20`. Maximum: `50`. | ||
- `offset`: The index of the first item to return. Default: `0`. | ||
- `time_range`: Over what time frame the data is retrieved. Options: `short_term`, `medium_term`, `long_term`. Default: `medium_term`. | ||
#### getUserProfile | ||
Get's another user's profile by ID | ||
```js | ||
const thekwoka = await client(getUserProfile('thekwoka')); | ||
``` | ||
## Special Utilities | ||
@@ -122,0 +153,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
35743
80
487
167