目錄
<h3 id="1">概述</h4>
這個(gè)搜索API允許你通過關(guān)鍵詞在你的網(wǎng)站上搜索iTunes Store,App Store, iBooks Store and Mac App Store。你可以搜索各種內(nèi)容;包括應(yīng)用、圖書、電影、廣播、音樂、視頻、有聲讀物以及TV節(jié)目。你也可以調(diào)用一個(gè)實(shí)名查詢請求來創(chuàng)建內(nèi)容庫之間的映射和數(shù)字目錄。開發(fā)者可以使用API里的推廣的內(nèi)容,包括歌曲預(yù)覽,音樂錄像,專輯封面和APP圖標(biāo)只用在推廣的店面,不用于娛樂用途。從API里使用音樂樣本及其他必須和店面徽章相似。條款和條件適用。
這項(xiàng)計(jì)劃允許當(dāng)你的網(wǎng)站或者app獲得點(diǎn)擊后獲得一些傭金。該項(xiàng)計(jì)劃更多信息請查看:http://www.apple.com/itunes/affiliates。
<h4 id= "2">搜索 iTunes Store</h4>
通過web去查找并且顯示結(jié)果在web網(wǎng)站上。你必須創(chuàng)建一個(gè)搜索區(qū)域,通過完全限定的URL請求iTunes Store,并從返回的結(jié)果中解析JSON。然后將結(jié)果顯示在web上。
完整的網(wǎng)址必須有以下格式:
https://itunes.apple.com/search?parameterkeyvalue
在參數(shù)里有一個(gè)或多個(gè)鍵值對(duì),來詳細(xì)說明你返回的結(jié)果。
構(gòu)造一個(gè)參數(shù)鍵值對(duì),你必須將每個(gè)參數(shù)的key等于(=)一個(gè)字符串value。例如:key1 =value1。創(chuàng)建一個(gè)字符串鍵值對(duì),你必須將每對(duì)鍵值對(duì)用與(&)符號(hào)鏈接。例如:key1=value1&key2=value2&key3=value3
注:當(dāng)您為網(wǎng)站創(chuàng)建搜索域和腳本時(shí),你應(yīng)該使用動(dòng)態(tài)腳本標(biāo)簽?zāi)愕腦MLHTTP腳本調(diào)用請求。例如:
<script src="https://.../search?parameterkeyvalue&callback="{name of JavaScript function in webpage}"/>
您可以使用下表定義的參數(shù)的key和value來搜索iTunes Store,App Store,iBooks商店和Mac App Store里面的內(nèi)容:

ps:實(shí)在不會(huì)用markdown來實(shí)現(xiàn)表格套表格。。。。
<h4 id="3">內(nèi)容</h4>
- 關(guān)鍵是要正確編碼你的URL才能被委托會(huì)員鏈接。在編碼原始鏈接附屬票據(jù)可以在Advanced Affiliate Linking的文檔中找到。
- 為了提高請求時(shí)間,通過指定適當(dāng)?shù)膌imit參數(shù),在檢索api的時(shí)候返回極少數(shù)的結(jié)果。
- 大型網(wǎng)站應(yīng)該建立緩存邏輯,檢索查找api的請求。為了說明這一點(diǎn),請稍后查看本篇文章的Caching Architecture。
<h4 id="4">搜索例子</h4>
以下是具體的搜索請求完全合格的URL的例子:
- 要搜索所有杰克·約翰遜的音頻和視頻內(nèi)容(電影,播客,音樂,音樂視頻,有聲讀物,電影短片和電視節(jié)目),您的網(wǎng)址將如下所示:
https://itunes.apple.com/search?term=jack+johnson - 要搜索所有杰克·約翰遜的音頻和視頻內(nèi)容(電影,播客,音樂,音樂視頻,有聲讀物,電影短片和電視節(jié)目),并且只返回前25條。您的網(wǎng)址將如下所示:
https://itunes.apple.com/search?term=jack+johnson&limit=25 - 要檢索杰克·約翰遜的音頻,您的網(wǎng)址將如下所示:
https://itunes.apple.com/search?term=jack+johnson&entity=musicVideo - 要搜索所有吉姆·瓊斯音頻和視頻內(nèi)容,并返回只從加拿大iTunes商店的結(jié)果,您的網(wǎng)址將如下所示:
https://itunes.apple.com/search?term=jim+jones&country=ca - 要搜索名為“Yelp的”應(yīng)用程序和來自美國的iTunes商店只返回的結(jié)果,您的網(wǎng)址將如下所示:
https://itunes.apple.com/search?term=yelp&country=us&entity=software
<h4 id="5">檢索例子</h4>
你也可以創(chuàng)建一個(gè)基于iTunes IDs, UPCs/ EANs的搜索請求去商店里面搜索內(nèi)容。和所有音樂指南(AMG)標(biāo)識(shí)的存儲(chǔ)內(nèi)容?;贗D的查找速度更快,而且含有較少的假陽性結(jié)果。
以下是具體的查找請求完全合格的URL的例子:
- 通過iTunes藝術(shù)家ID查找杰克·約翰遜:
https://itunes.apple.com/lookup?id=909253 - 通過iTunes ID查找Yelp的軟件應(yīng)用程序:
https://itunes.apple.com/lookup?id=284910350 - 通過AMG藝術(shù)家ID查找杰克·約翰遜:
https://itunes.apple.com/lookup?amgArtistId=468749 - 通過AMG藝術(shù)家的ID查找多個(gè)藝術(shù)家:
https://itunes.apple.com/lookup?amgArtistId=468749,5723 - 查找的杰克·約翰遜的所有專輯:
https://itunes.apple.com/lookup?id=909253&entity=album - 其AMG藝術(shù)家的ID查找多個(gè)藝術(shù)家和獲得每個(gè)藝術(shù)家的前5張專輯:
https://itunes.apple.com/lookup?amgArtistId=468749,5723&entity=album&limit=5 - 通過AMG藝術(shù)家的ID查找多個(gè)藝術(shù)家和獲得每個(gè)藝術(shù)家的5最新歌曲:
https://itunes.apple.com/lookup?amgArtistId=468749,5723&entity=song&limit=5&sort=recent - 通過UPC查找一個(gè)專輯或視頻:
https://itunes.apple.com/lookup?upc=720642462928 - 通過UPC查找專輯,包括這張專輯的曲目:
https://itunes.apple.com/lookup?upc=720642462928&entity=song - 通過專輯ID來查找一個(gè)專輯:
https://itunes.apple.com/lookup?amgAlbumId=15175,15176,15177,15178,15183,15184,15187,1519,15191,15195,15197,15198 - 通過AMG視頻ID查找一部電影:
https://itunes.apple.com/lookup?amgVideoId=17120 - 通過13位ISBN查找一本書:
https://itunes.apple.com/lookup?isbn=9780316069359
<h4 id="6">了解搜索結(jié)果</h4>
你搜索的結(jié)果用JSON格式返回,JSON有兩種結(jié)構(gòu):
- 一種key/value的集合。也可以稱之為一種對(duì)象,這個(gè)概念類似于Java Map對(duì)象,一個(gè)Javascript字典,或Pearl/ Ruby的哈希值。對(duì)象是一個(gè)無序的名稱/值對(duì),用左括號(hào)開始({)和一個(gè)右括號(hào)結(jié)束(})。每個(gè)名稱由雙引號(hào)包圍,后跟一個(gè)冒號(hào)(:));名稱/值對(duì)用逗號(hào)(,)隔開。
- 值的有序列表,也稱為陣列。數(shù)組是值的有序集合,用左括號(hào)開頭([),并以右括號(hào)結(jié)束(])。值用逗號(hào)(,)分隔。
所有的JSON結(jié)果被編碼為UTF-8。有關(guān)JSON的更多信息,請參閱http://www.json.org。
下面的示例顯示在iTunes Store的歌曲JSON的結(jié)果
{"wrapperType":"track",
"kind":"song",
"artistId":909253,
"collectionId":120954021,
"trackId":120954025,
"artistName":"Jack Johnson",
"collectionName":"Sing-a-Longs and Lullabies for the Film Curious George",
"trackName":"Upside Down",
"collectionCensoredName":"Sing-a-Longs and Lullabies for the Film Curious George",
"trackCensoredName":"Upside Down",
"artistViewUrl":"https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewArtist?id=909253",
"collectionViewUrl":"https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewAlbum?i=120954025&id=120954021&s=143441",
"trackViewUrl":"https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewAlbum?i=120954025&id=120954021&s=143441",
"previewUrl":"http://a1099.itunes.apple.com/r10/Music/f9/54/43/mzi.gqvqlvcq.aac.p.m4p",
"artworkUrl60":"http://a1.itunes.apple.com/r10/Music/3b/6a/33/mzi.qzdqwsel.60x60-50.jpg",
"artworkUrl100":"http://a1.itunes.apple.com/r10/Music/3b/6a/33/mzi.qzdqwsel.100x100-75.jpg",
"collectionPrice":10.99,
"trackPrice":0.99,
"collectionExplicitness":"notExplicit",
"trackExplicitness":"notExplicit",
"discCount":1,
"discNumber":1,
"trackCount":14,
"trackNumber":1,
"trackTimeMillis":210743,
"country":"USA",
"currency":"USD",
"primaryGenreName":"Rock"}
下表定義了JSON格式返回結(jié)果的鍵和值:
| key | 描述 | 是否返回 | 返回值以及例子 |
|---|---|---|---|
| wrapperType | The name of the object returned by the search request. | Y | track, collection, artistFor example: track. |
| * explicitness | The Recording Industry Association of America (RIAA) parental advisory for the content returned by the search request.For more information, see http://itunes.apple.com/WebObjects/MZStore.woa/wa/parentalAdvisory | Y | explicit (explicit lyrics, possibly explicit album cover), cleaned (explicit lyrics “bleeped out”), notExplicit (no explicit lyrics)For example: “trackExplicitness”:”notExplicit”. |
| kind | The kind of content returned by the search request. | Y | book, album, coached-audio, feature-movie, interactive- booklet, music-video, pdf podcast, podcast-episode, software-package, song, tv- episode, artistFor example: song. |
| trackName | The name of the track, song, video, TV episode, and so on returned by the search request. | y | For example: “Banana Pancakes”. |
| artistName | The name of the artist returned by the search request. | Y | For example: Jack Johnson. |
| collectionName | The name of the album, TV season, audiobook, and so on returned by the search request. | Y | For example: “In Between Dreams”. |
| *censoredName | The name of the album, TV season, audiobook, and so on returned by the search request, with objectionable words *’d out.Note: Artist names are never censored. | Y | For example: “S**t Happens”. |
| artworkUrl100, artworkUrl60 | A URL for the artwork associated with the returned media type, sized to 100×100 pixels or 60×60 pixels. | Only returned when artwork is available | For example: “[http:// a1.itunes.apple.com/jp/r10/Music/ y2005/m06/d03/h05/ s05.oazjtxkw.100×100-75.jpg](http:// a1.itunes.apple.com/jp/r10/Music/ y2005/m06/d03/h05/ s05.oazjtxkw.100×100-75.jpg)”. |
| *viewURL | A URL for the content associated with the returned media type. You can click the URL to view the content in the iTunes Store. | Y | For example: “[http:// itunes.apple.com/WebObjects/ MZStore.woa/wa/viewAlbum? i=68615807&id=68615813&s=1434 62](http:// itunes.apple.com/WebObjects/ MZStore.woa/wa/viewAlbum? i=68615807&id=68615813&s=1434 62)”. |
| previewUrl | A URL referencing the 30-second preview file for the content associated with the returned media type. | Only returned when media type is track | For example: “[http:// a392.itunes.apple.com/jp/r10/ Music/y2005/m06/d03/h05/s05.zdzqlufu.p.m4p](http:// a392.itunes.apple.com/jp/r10/ Music/y2005/m06/d03/h05/s05.zdzqlufu.p.m4p)”. |
| trackTimeMillis | The returned track’s time in milliseconds. | Only returned when media type is track | 無 |
<h4 id='7'>緩存框架</h4>

<h4 id="8">法律聲明</h4>
開發(fā)人員可以使用某些促銷內(nèi)容,可以通過蘋果公司提供,包括歌曲預(yù)覽和音樂視頻,專輯封面,和App圖標(biāo)(“促銷內(nèi)容”),促進(jìn)了促銷內(nèi)容的主題的目的;提供了這種促銷內(nèi)容:(一)被放置僅在促進(jìn)該促銷內(nèi)容是基于內(nèi)容頁面; (二)是接近了“iTunes下載”,“下載的應(yīng)用程序商店”或“下載的iBooks商店”標(biāo)志(如批準(zhǔn)蘋果公司)充當(dāng)直接鏈接到iTunes中或App Store頁面,消費(fèi)者可以購買該宣傳內(nèi)容; (三)包括歸屬指示促銷內(nèi)容是“提供了iTunes的禮遇”如果這樣的促銷內(nèi)容包括歌曲或音樂視頻預(yù)覽; (四)僅流,而不是下載,保存,緩存,或者與視頻同步,如果這樣的促銷內(nèi)容包括歌曲或音樂視頻預(yù)覽; (五)不用于除了其促銷目的獨(dú)立娛樂價(jià)值;及(六)不用于促進(jìn)任何其他商品或服務(wù)。開發(fā)商承認(rèn),蘋果提供的促銷內(nèi)容的“原樣”,并拒絕任何和所有陳述或擔(dān)保,包括但不限于非侵權(quán)。開發(fā)者應(yīng)將與促銷內(nèi)容到蘋果在收到立即連接收到任何索賠,并將根據(jù)要求蘋果公司立刻刪除任何促銷內(nèi)容。
本協(xié)議和您的宣傳內(nèi)容使用受加利福尼亞州法律管轄。