New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

itunes-web-api

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

itunes-web-api - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

16

package.json
{
"name": "itunes-web-api",
"version": "1.0.4",
"description": "iTunes WEB API Scrapper",
"version": "1.0.5",
"description": "iTunes WEB API Scrapper. Get iTunes track/trackvideo/artist/album/movie/app/book/voicebook/podcast infos with their names.",
"main": "index.js",
"keywords": [
"itunes",
"itunes-api",
"fetch-itunesapi",
"apple",
"apple-api",
"itunes-web"
],
"scripts": {

@@ -11,2 +19,6 @@ "test": "echo \"Error: no test specified\" && exit 1"

"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/BilalTaner/itunes-web-api.git"
},
"dependencies": {

@@ -13,0 +25,0 @@ "node-fetch": "^2.6.1"

## WELCOME TO ITUNES WEB API!
## WARNING!! (IF U ARE USING VER 1.0.3 or LOWER PLEASE UPDATE YOUR MODULE)
### EXAMPLE FOR NEW VERSION (OPTIONS UPDATE)
### NOTE: OPTIONS ARE OPTIONAL NOT NECESSARY
## WARNING!! (IF U ARE USING VER 1.0.4 or LOWER PLEASE UPDATE YOUR MODULE)
### NOTE: OPTIONS ARE OPTIONAL - NOT NECESSARY
NOTE:
If you do not enter limit, lang or country values, the default language and country code are set to English. Limit Number default is 1.
Please Check [ISO_3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) For Language and Country Codes.
### EXAMPLE FOR USAGE
````js

@@ -12,2 +17,14 @@ //##### USAGE FOR TRACK INFO #####\\

//##### USAGE FOR TRACK-VIDEO INFO #####\\
const itunes = require('itunes-api');
let data = await itunes.trackVideo(songName, {limit: Number, lang: 'lang-code', country: 'country-code'})
console.log(data) //album infos in resulst array
//##### USAGE FOR ARTIST INFO #####\\
const itunes = require('itunes-api');
let data = await itunes.artist(artistName, {limit: Number, lang: 'lang-code', country: 'country-code'})
console.log(data) //album infos in resulst array
//##### USAGE FOR ALBUM INFO #####\\

@@ -47,5 +64,18 @@ const itunes = require('itunes-api');

console.log(data)//podcast infos in resulst array
//##### USAGE FOR ALL INFO #####\\
const itunes = require('itunes-api');
let data = await itunes.searchAll(searchString, entity, attribute, {limit: Number, lang: 'lang-code', country: 'country-code'})
//entity examples === movie, album, allArtist, podcast, musicVideo, mix, audiobook, tvSeason, allTrack
//attribute examples === actorTerm, languageTerm, allArtistTerm, tvEpisodeTerm, shortFilmTerm, directorTerm, releaseYearTerm, titleTerm, featureFilmTerm, ratingIndex, keywordsTerm, descriptionTerm, authorTerm, genreIndex, mixTerm, allTrackTerm, artistTerm, composerTerm, tvSeasonTerm, producerTerm, ratingTerm, songTerm, movieArtistTerm, showTerm, movieTerm, albumTerm
console.log(data)//string infos in resulst array
````
##### EXAMPLE OUTPUT FOR TRACK
```js
const itunes = require('itunes-api');
let data = await itunes.track(songName, {limit: Number, lang: 'lang-code', country: 'country-code'})
console.log(data)
/* data OUTPUT
{

@@ -89,3 +119,3 @@ resultCount: 1,

]
}
}*/
```

@@ -92,0 +122,0 @@ ## WARNING!!

@@ -18,3 +18,3 @@ const fetch = require("node-fetch");

}
if(response.errorMessage && lang && country || response.errorMessage && lang || response.errorMessage) {
if(response.errorMessage && options.lang && options.country || response.errorMessage && options.lang || response.errorMessage) {
console.error(`Unspecified Language or Country. ERROR: ${response.errorMessage}\nPlease Check https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2`);

@@ -25,2 +25,42 @@ return undefined;

},
async trackVideo(songName, options = {}){
if(!songName) return console.log('ERROR: You must enter a Valid Song Name!')
if(options.limit > 200) return console.log("ERROR: Limit number cannot be more than 200.")
if(!options.limit || options.limit === null || options.limit === undefined || options.limit === 0) options.limit = 1
if(isNaN(options.lang) === false) return console.log("ERROR: Language cannot be number.")
if(!options.lang || options.lang === null || options.lang === undefined || options.lang === 0) options.lang = 'en'
if(isNaN(options.country) === false) return console.log("ERROR: Country cannot be number.")
if(!options.country || options.country === null || options.country === undefined || options.country === 0) options.country = 'US'
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(songName)}&media=musicVideo&limit=${options.limit}&lang=${options.lang}&country=${options.country}`);
const response = await res.json();
if(response.resultCount === 0) {
console.error("ERROR: This Song is doesn't exist.");
return undefined;
}
if(response.errorMessage && options.lang && options.country || response.errorMessage && options.lang || response.errorMessage) {
console.error(`Unspecified Language or Country. ERROR: ${response.errorMessage}\nPlease Check https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2`);
return undefined;
}
return response;
},
async artist(artistName, options = {}){
if(!artistName) return console.log('ERROR: You must enter a Valid Album Name!')
if(options.limit > 200) return console.log("ERROR: Limit number cannot be more than 200.")
if(!options.limit || options.limit === null || options.limit === undefined || options.limit === 0) options.limit = 1
if(isNaN(options.lang) === false) return console.log("ERROR: Language cannot be number.")
if(!options.lang || options.lang === null || options.lang === undefined || options.lang === 0) options.lang = 'en'
if(isNaN(options.country) === false) return console.log("ERROR: Country cannot be number.")
if(!options.country || options.country === null || options.country === undefined || options.country === 0) options.country = 'US'
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(artistName)}&entity=allArtist&attribute=allArtistTerm&limit=${options.limit}&lang=${options.lang}&country=${options.country}`);
const response = await res.json();
if(response.resultCount === 0) {
console.error("ERROR: This Album is doesn't exist.");
return undefined;
}
if(response.errorMessage && options.lang && options.country || response.errorMessage && options.lang || response.errorMessage) {
console.error(`Unspecified Language or Country. ERROR: ${response.errorMessage}\nPlease Check https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2`);
return undefined;
}
return response;
},
async album(albumName, options = {}){

@@ -40,3 +80,3 @@ if(!albumName) return console.log('ERROR: You must enter a Valid Album Name!')

}
if(response.errorMessage && lang && country || response.errorMessage && lang || response.errorMessage) {
if(response.errorMessage && options.lang && options.country || response.errorMessage && options.lang || response.errorMessage) {
console.error(`Unspecified Language or Country. ERROR: ${response.errorMessage}\nPlease Check https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2`);

@@ -61,3 +101,3 @@ return undefined;

}
if(response.errorMessage && lang && country || response.errorMessage && lang || response.errorMessage) {
if(response.errorMessage && options.lang && options.country || response.errorMessage && options.lang || response.errorMessage) {
console.error(`Unspecified Language or Country. ERROR: ${response.errorMessage}\nPlease Check https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2`);

@@ -82,3 +122,3 @@ return undefined;

}
if(response.errorMessage && lang && country || response.errorMessage && lang || response.errorMessage) {
if(response.errorMessage && options.lang && options.country || response.errorMessage && options.lang || response.errorMessage) {
console.error(`Unspecified Language or Country. ERROR: ${response.errorMessage}\nPlease Check https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2`);

@@ -103,3 +143,3 @@ return undefined;

}
if(response.errorMessage && lang && country || response.errorMessage && lang || response.errorMessage) {
if(response.errorMessage && options.lang && options.country || response.errorMessage && options.lang || response.errorMessage) {
console.error(`Unspecified Language or Country. ERROR: ${response.errorMessage}\nPlease Check https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2`);

@@ -124,3 +164,3 @@ return undefined;

}
if(response.errorMessage && lang && country || response.errorMessage && lang || response.errorMessage) {
if(response.errorMessage && options.lang && options.country || response.errorMessage && options.lang || response.errorMessage) {
console.error(`Unspecified Language or Country. ERROR: ${response.errorMessage}\nPlease Check https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2`);

@@ -145,3 +185,3 @@ return undefined;

}
if(response.errorMessage && lang && country || response.errorMessage && lang || response.errorMessage) {
if(response.errorMessage && options.lang && options.country || response.errorMessage && options.lang || response.errorMessage) {
console.error(`Unspecified Language or Country. ERROR: ${response.errorMessage}\nPlease Check https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2`);

@@ -151,3 +191,27 @@ return undefined;

return response;
},
async searchAll(searchString, entity, attribute, options = {}){
if(!searchString) return console.log('ERROR: You must enter a string for search!')
if(!entity) return console.log('ERROR: You must enter a entity! Example entitys = (movie, album, allArtist, podcast, musicVideo, mix, audiobook, tvSeason, allTrack)')
if(isNaN(entity) === false) return console.log("ERROR: Entity cannot be number.")
if(!attribute) return console.log('ERROR: You must enter a attribute! Example attributes = (actorTerm, languageTerm, allArtistTerm, tvEpisodeTerm, shortFilmTerm, directorTerm, releaseYearTerm, titleTerm, featureFilmTerm, ratingIndex, keywordsTerm, descriptionTerm, authorTerm, genreIndex, mixTerm, allTrackTerm, artistTerm, composerTerm, tvSeasonTerm, producerTerm, ratingTerm, songTerm, movieArtistTerm, showTerm, movieTerm, albumTerm)')
if(isNaN(attribute) === false) return console.log("ERROR: Attribute cannot be number.")
if(options.limit > 200) return console.log("ERROR: Limit number cannot be more than 200.")
if(!options.limit || options.limit === null || options.limit === undefined || options.limit === 0) options.limit = 1
if(isNaN(options.lang) === false) return console.log("ERROR: Language cannot be number.")
if(!options.lang || options.lang === null || options.lang === undefined || options.lang === 0) options.lang = 'en'
if(isNaN(options.country) === false) return console.log("ERROR: Country cannot be number.")
if(!options.country || options.country === null || options.country === undefined || options.country === 0) options.country = 'US'
const res = await fetch(`https://itunes.apple.com/search?term=${searchString}&entity=${entity}&attribute=${attribute}&limit=${options.limit}&lang=${options.lang}&country=${options.country}`);
const response = await res.json();
if(response.resultCount === 0) {
console.error("ERROR: Resulsts are doesn't exist.");
return undefined;
}
if(response.errorMessage && options.lang && options.country || response.errorMessage && options.lang || response.errorMessage) {
console.error(`Unspecified Language or Country or Strings. ERROR: ${response.errorMessage}\nPlease Check https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2`);
return undefined;
}
return response;
}
}

5

test.js
const itunes = require('itunes-web-api');
(async() => {
let data = await itunes.track('Lil Nas Rodeo', {limit: 1, lang: 'en', country: 'US'})
console.log(data)})()
let data = await itunes.trackVideo('Drake - Jumpman', {limit: 1, lang: 'en', country: 'US'})
console.log(data)
})()
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc