1.0.0 • Published 3 years ago

itunes-api-js v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

itunes-api-js

Simple promise-based library that provides helper functions and request validation for the iTunes Search API and the iTunes Lookup API.

Installation

itunes-api-js is intended for use in the browser and does not support Node.

Usage

Import the package:

import iTunes from "itunes-api-js";

Search

The search method takes a required search term and optional addlParam object and returns a promise:

iTunes.search(term, addlParam);

// Examples
iTunes.search("Pheobe Bridgers");
iTunes.search("Phoebe Bridgers", { entity: "song", limit: 10 });
addlParam propertytypevalue
countryStringISO 3166-1 alpha-2 country code
mediaStringList
entityStringList
attributeStringList
limitNumber1 to 200
langStringen_us or ja_jp
versionNumber1 or 2
explicitStringyes or no

Lookup

There are several lookup methods corresponding to the different types of identifiers supported by the iTunes API:

  • iTunes.lookup.id(id, addlParam): iTunes or App Store ID
  • iTunes.lookup.url(url, addlParam): iTunes or Apple Music URL
  • iTunes.lookup.upc(upc, addlParam): Universal Product Code (barcode)
  • iTunes.lookup.isbn(isbn, addlParam): ISBN-13 (ISBN-10 appears to work, but the documentation claims otherwise)
  • iTunes.lookup.amgArtistId(id, addlParam): All Music Guide artist ID
  • iTunes.lookup.amgAlbumId(id, addlParam): All Music Guide album ID
  • iTunes.lookup.amgVideoId(id, addlParam): All Music Guide video ID

Lookup requests are faster and more accurate than search requests. Each lookup method returns a promise and takes an identifier, such as an iTunes ID, or an array of identifiers and a second optional parameter called addlParam which can be used to specify additional search options:

addlParam propertytypevalue
entityStringList
limitNumber1 to 200
sortString"recent"
// Examples
iTunes.lookup.id("1033453223", { entity: "song", limit: 25, sort: "recent" });
iTunes.lookup.id(["1543461018", "1543461013"]);
1.0.0

3 years ago