GithubHelp home page GithubHelp logo

spotify-api / spotify-types Goto Github PK

View Code? Open in Web Editor NEW
21.0 1.0 3.0 54 KB

All the typings for the various Spotify API Object typings written in typescript.

Home Page: https://www.npmjs.com/package/spotify-types

License: MIT License

TypeScript 100.00%
spotify spotify-api typings spotify-types typescript

spotify-types's Introduction

Spotify Types

Module Documentation Reference: https://spotify-api.js.org/apiTypes/
Spotify Object Index Reference: https://developer.spotify.com/documentation/web-api/reference/#objects-index

All the typings for the various Spotify API Object typings written in typescript. You can view the Spotify web api reference for all the objects here.

This is a typings modules made for Spotify-api.js v9. This can also be used separately just for typescript debugging when working with Spotify API. This package can be even used in deno using the cdn urls.

import { SearchContent } from "spotify-types";
import axios, { AxiosResponse } from "axios";

const response: AxiosResponse<SearchContent> = await axios.get('https://api.spotify.com/v1/search', {
    headers: { "Authorization": "Bearer " + process.env.SPOTIFY_TOKEN },
    params: {
        q: "search query",
        type: "track",
        market: "US"
    }
});

spotify-types's People

Contributors

hawyar avatar scientific-dev avatar t1mofe1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spotify-types's Issues

Allow users to narrow down type

Hi! Thank you for creating a great package. However, while using it, I noticed I couldn't narrow down the object types using standard TS type guards. For example, given an item: Track | Episode; I can't narrow it down to Track by simply checking item.type === "episode".

This happens because all interfaces share the same SpotifyType, which doesn't guarantee an Episode will always have a "episode" as a type.

Could we change them to simple literal types to benefit from type narrowing? I'd like to file a PR if you're interested.

Add types for token

I would like to have types for the token object returned from the access token request.

interface Token {
  accessToken: string;
  tokenType: string;
  expiresIn: number;
}

I can open a PR for it. Thank you

Missing return type for '/me/following' endpoint

See docs here. Suggested type below:

interface FollowedArtistCursors {
  /** The cursor to use as key to find the next page of items. */
  after: string;
  /** The cursor to use as key to find the previous page of items. */
  before: string;
}

interface FollowedArtistCursorPaging<T> {
  /** A link to the Web API endpoint returning the full result of the request. */
  href: string;
  /** The maximum number of items in the response (as set in the query or by default). */
  limit: number;
  /** URL to the next page of items. (null if none) */
  next: string;
  /** The cursors used to find the next set of items. */
  cursors: FollowedArtistCursors;
  /** The total number of items available to return. */
  total: number;
  /** The requested data. */
  items: T[];
}

interface FollowedArtistsResults {
  artists: FollowedArtistCursorPaging<Artist>;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.