目錄
<h3 id="1">概述</h4>
這個搜索API允許你通過關鍵詞在你的網站上搜索iTunes Store,App Store, iBooks Store and Mac App Store。你可以搜索各種內容;包括應用、圖書、電影、廣播、音樂、視頻、有聲讀物以及TV節目。你也可以調用一個實名查詢請求來創建內容庫之間的映射和數字目錄。開發者可以使用API里的推廣的內容,包括歌曲預覽,音樂錄像,專輯封面和APP圖標只用在推廣的店面,不用于娛樂用途。從API里使用音樂樣本及其他必須和店面徽章相似。條款和條件適用。
這項計劃允許當你的網站或者app獲得點擊后獲得一些傭金。該項計劃更多信息請查看:http://www.apple.com/itunes/affiliates。
<h4 id= "2">搜索 iTunes Store</h4>
通過web去查找并且顯示結果在web網站上。你必須創建一個搜索區域,通過完全限定的URL請求iTunes Store,并從返回的結果中解析JSON。然后將結果顯示在web上。
完整的網址必須有以下格式:
https://itunes.apple.com/search?parameterkeyvalue
在參數里有一個或多個鍵值對,來詳細說明你返回的結果。
構造一個參數鍵值對,你必須將每個參數的key等于(=)一個字符串value。例如:key1 =value1。創建一個字符串鍵值對,你必須將每對鍵值對用與(&)符號鏈接。例如:key1=value1&key2=value2&key3=value3
注:當您為網站創建搜索域和腳本時,你應該使用動態腳本標簽你的XMLHTTP腳本調用請求。例如:
<script src="https://.../search?parameterkeyvalue&callback="{name of JavaScript function in webpage}"/>
您可以使用下表定義的參數的key和value來搜索iTunes Store,App Store,iBooks商店和Mac App Store里面的內容:
ps:實在不會用markdown來實現表格套表格。。。。
<h4 id="3">內容</h4>
- 關鍵是要正確編碼你的URL才能被委托會員鏈接。在編碼原始鏈接附屬票據可以在Advanced Affiliate Linking的文檔中找到。
- 為了提高請求時間,通過指定適當的limit參數,在檢索api的時候返回極少數的結果。
- 大型網站應該建立緩存邏輯,檢索查找api的請求。為了說明這一點,請稍后查看本篇文章的Caching Architecture。
<h4 id="4">搜索例子</h4>
以下是具體的搜索請求完全合格的URL的例子:
- 要搜索所有杰克·約翰遜的音頻和視頻內容(電影,播客,音樂,音樂視頻,有聲讀物,電影短片和電視節目),您的網址將如下所示:
https://itunes.apple.com/search?term=jack+johnson - 要搜索所有杰克·約翰遜的音頻和視頻內容(電影,播客,音樂,音樂視頻,有聲讀物,電影短片和電視節目),并且只返回前25條。您的網址將如下所示:
https://itunes.apple.com/search?term=jack+johnson&limit=25 - 要檢索杰克·約翰遜的音頻,您的網址將如下所示:
https://itunes.apple.com/search?term=jack+johnson&entity=musicVideo - 要搜索所有吉姆·瓊斯音頻和視頻內容,并返回只從加拿大iTunes商店的結果,您的網址將如下所示:
https://itunes.apple.com/search?term=jim+jones&country=ca - 要搜索名為“Yelp的”應用程序和來自美國的iTunes商店只返回的結果,您的網址將如下所示:
https://itunes.apple.com/search?term=yelp&country=us&entity=software
<h4 id="5">檢索例子</h4>
你也可以創建一個基于iTunes IDs, UPCs/ EANs的搜索請求去商店里面搜索內容。和所有音樂指南(AMG)標識的存儲內容。基于ID的查找速度更快,而且含有較少的假陽性結果。
以下是具體的查找請求完全合格的URL的例子:
- 通過iTunes藝術家ID查找杰克·約翰遜:
https://itunes.apple.com/lookup?id=909253 - 通過iTunes ID查找Yelp的軟件應用程序:
https://itunes.apple.com/lookup?id=284910350 - 通過AMG藝術家ID查找杰克·約翰遜:
https://itunes.apple.com/lookup?amgArtistId=468749 - 通過AMG藝術家的ID查找多個藝術家:
https://itunes.apple.com/lookup?amgArtistId=468749,5723 - 查找的杰克·約翰遜的所有專輯:
https://itunes.apple.com/lookup?id=909253&entity=album - 其AMG藝術家的ID查找多個藝術家和獲得每個藝術家的前5張專輯:
https://itunes.apple.com/lookup?amgArtistId=468749,5723&entity=album&limit=5 - 通過AMG藝術家的ID查找多個藝術家和獲得每個藝術家的5最新歌曲:
https://itunes.apple.com/lookup?amgArtistId=468749,5723&entity=song&limit=5&sort=recent - 通過UPC查找一個專輯或視頻:
https://itunes.apple.com/lookup?upc=720642462928 - 通過UPC查找專輯,包括這張專輯的曲目:
https://itunes.apple.com/lookup?upc=720642462928&entity=song - 通過專輯ID來查找一個專輯:
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">了解搜索結果</h4>
你搜索的結果用JSON格式返回,JSON有兩種結構:
- 一種key/value的集合。也可以稱之為一種對象,這個概念類似于Java Map對象,一個Javascript字典,或Pearl/ Ruby的哈希值。對象是一個無序的名稱/值對,用左括號開始({)和一個右括號結束(})。每個名稱由雙引號包圍,后跟一個冒號(:));名稱/值對用逗號(,)隔開。
- 值的有序列表,也稱為陣列。數組是值的有序集合,用左括號開頭([),并以右括號結束(])。值用逗號(,)分隔。
所有的JSON結果被編碼為UTF-8。有關JSON的更多信息,請參閱http://www.json.org。
下面的示例顯示在iTunes Store的歌曲JSON的結果
{"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格式返回結果的鍵和值:
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>
開發人員可以使用某些促銷內容,可以通過蘋果公司提供,包括歌曲預覽和音樂視頻,專輯封面,和App圖標(“促銷內容”),促進了促銷內容的主題的目的;提供了這種促銷內容:(一)被放置僅在促進該促銷內容是基于內容頁面; (二)是接近了“iTunes下載”,“下載的應用程序商店”或“下載的iBooks商店”標志(如批準蘋果公司)充當直接鏈接到iTunes中或App Store頁面,消費者可以購買該宣傳內容; (三)包括歸屬指示促銷內容是“提供了iTunes的禮遇”如果這樣的促銷內容包括歌曲或音樂視頻預覽; (四)僅流,而不是下載,保存,緩存,或者與視頻同步,如果這樣的促銷內容包括歌曲或音樂視頻預覽; (五)不用于除了其促銷目的獨立娛樂價值;及(六)不用于促進任何其他商品或服務。開發商承認,蘋果提供的促銷內容的“原樣”,并拒絕任何和所有陳述或擔保,包括但不限于非侵權。開發者應將與促銷內容到蘋果在收到立即連接收到任何索賠,并將根據要求蘋果公司立刻刪除任何促銷內容。
本協議和您的宣傳內容使用受加利福尼亞州法律管轄。