Soundcloud API - 按created_at订购结果

时间:2012-05-16 02:19:52

标签: get soundcloud

我正在尝试向SoundCloud API执行GET请求,该请求按搜索字词提取最近的5首曲目。这是我的查询网址:

'http://api.soundcloud.com/tracks.json?{client_id={}&q={search_term}&limit=5&streamable=true&order=created_at'

但是,这不会按created_at的顺序返回曲目。我宁愿不必解析最新曲目的数据。我也试过order=latest

修改:这是我的确切查询网址(减去客户端ID)和输出:

http://api.soundcloud.com/tracks.json?client_id={}&q=the%20fray&limit=5&streamable=true&order=created_at


[ { kind: 'track',
id: 16393251,
created_at: '2011/06/02 13:44:54 +0000',
user_id: 3050663,
duration: 40269,
commentable: true,
state: 'finished',
original_content_size: 1337259,
sharing: 'public',
tag_list: '',
permalink: 'the-fray',
description: '',
streamable: true,
downloadable: false,
genre: '',
release: '',
purchase_url: null,
purchase_title: null,
label_id: null,
label_name: '',
isrc: '',
video_url: null,
track_type: '',
key_signature: '',
bpm: null,
title: 'The Fray',
release_year: null,
release_month: null,
release_day: null,
original_format: 'm4a',
license: 'all-rights-reserved',
uri: 'http://api.soundcloud.com/tracks/16393251',
permalink_url: 'http://soundcloud.com/justasterisms/the-fray',
artwork_url: null,
waveform_url: 'http://w1.sndcdn.com/YcZLLwkjn2oz_m.png',
user: 
 { id: 3050663,
   kind: 'user',
   permalink: 'justasterisms',
   username: 'justasterisms',
   uri: 'http://api.soundcloud.com/users/3050663',
   permalink_url: 'http://soundcloud.com/justasterisms',
   avatar_url: 'http://a1.sndcdn.com/images/default_avatar_large.png?2262bae' },
stream_url: 'http://api.soundcloud.com/tracks/16393251/stream',
playback_count: 1676,
download_count: 0,
favoritings_count: 6,
comment_count: 0,
attachments_uri: 'http://api.soundcloud.com/tracks/16393251/attachments' },
{ kind: 'track',
id: 45035516,
created_at: '2012/05/02 04:42:13 +0000',
user_id: 16225631,
duration: 175530,
commentable: true,
state: 'finished',
original_content_size: 4213990,
sharing: 'public',
tag_list: '',
permalink: 'fray-fowling',
description: '',
streamable: true,
downloadable: true,
genre: '',
release: '',
purchase_url: null,
purchase_title: null,
label_id: null,
label_name: '',
isrc: '',
video_url: null,
track_type: '',
key_signature: '',
bpm: null,
title: 'Fray Fowling',
release_year: null,
release_month: null,
release_day: null,
original_format: 'mp3',
license: 'all-rights-reserved',
uri: 'http://api.soundcloud.com/tracks/45035516',
permalink_url: 'http://soundcloud.com/the-talismen/fray-fowling',
artwork_url: null,
waveform_url: 'http://w1.sndcdn.com/cw8gJ5nC2QHr_m.png',
user: 
 { id: 16225631,
   kind: 'user',
   permalink: 'the-talismen',
   username: 'The Talismen',
   uri: 'http://api.soundcloud.com/users/16225631',
   permalink_url: 'http://soundcloud.com/the-talismen',
   avatar_url: 'http://a1.sndcdn.com/images/default_avatar_large.png?2262bae' },
stream_url: 'http://api.soundcloud.com/tracks/45035516/stream',
download_url: 'http://api.soundcloud.com/tracks/45035516/download',
playback_count: 63,
download_count: 4,
favoritings_count: 0,
comment_count: 0,
attachments_uri: 'http://api.soundcloud.com/tracks/45035516/attachments' },
{ kind: 'track',
id: 26629456,
created_at: '2011/10/28 19:23:40 +0000',
user_id: 8445112,
duration: 159956,
commentable: true,
state: 'finished',
original_content_size: 4094284,
sharing: 'public',
tag_list: '',
permalink: 'samora-the-fray',
description: '',
streamable: true,
downloadable: false,
genre: 'Metal',
release: '',
purchase_url: null,
purchase_title: null,
label_id: null,
label_name: '',
isrc: null,
video_url: null,
track_type: null,
key_signature: null,
bpm: null,
title: 'Samora - The Fray',
release_year: null,
release_month: null,
release_day: null,
original_format: 'mp3',
license: 'all-rights-reserved',
uri: 'http://api.soundcloud.com/tracks/26629456',
permalink_url: 'http://soundcloud.com/theundergroundtour/samora-the-fray',
artwork_url: 'http://i1.sndcdn.com/artworks-000013441907-zfq9uz-large.jpg?2262bae',
waveform_url: 'http://w1.sndcdn.com/PGZOOd4DRbp4_m.png',
user: 
 { id: 8445112,
   kind: 'user',
   permalink: 'theundergroundtour',
   username: 'The Underground Tour',
   uri: 'http://api.soundcloud.com/users/8445112',
   permalink_url: 'http://soundcloud.com/theundergroundtour',
   avatar_url: 'http://i1.sndcdn.com/avatars-000007060505-pny4ej-large.jpg?2262bae' },
stream_url: 'http://api.soundcloud.com/tracks/26629456/stream',
playback_count: 811,
download_count: 0,
favoritings_count: 4,
comment_count: 0,
attachments_uri: 'http://api.soundcloud.com/tracks/26629456/attachments' },
{ kind: 'track',
id: 43622727,
created_at: '2012/04/19 04:37:43 +0000',
user_id: 15152175,
duration: 212011,
commentable: true,
state: 'finished',
original_content_size: 1752217,
sharing: 'public',
tag_list: 'soundcloud:source=iphone-record',
permalink: 'the-fray-heartbeat',
description: null,
streamable: true,
downloadable: true,
genre: null,
release: null,
purchase_url: null,
purchase_title: null,
label_id: null,
label_name: null,
isrc: null,
video_url: null,
track_type: 'recording',
key_signature: null,
bpm: null,
title: 'The Fray -- heartbeat',
release_year: null,
release_month: null,
release_day: null,
original_format: 'm4a',
license: 'all-rights-reserved',
uri: 'http://api.soundcloud.com/tracks/43622727',
permalink_url: 'http://soundcloud.com/nataliazea/the-fray-heartbeat',
artwork_url: 'http://i1.sndcdn.com/artworks-000021902063-s1cezf-large.jpg?2262bae',
waveform_url: 'http://w1.sndcdn.com/2IToTsm3iiCv_m.png',
user: 
 { id: 15152175,
   kind: 'user',
   permalink: 'nataliazea',
   username: 'nataliazea',
   uri: 'http://api.soundcloud.com/users/15152175',
   permalink_url: 'http://soundcloud.com/nataliazea',
   avatar_url: 'http://i1.sndcdn.com/avatars-000013390559-q9pep5-large.jpg?2262bae' },
stream_url: 'http://api.soundcloud.com/tracks/43622727/stream',
download_url: 'http://api.soundcloud.com/tracks/43622727/download',
playback_count: 563,
download_count: 45,
favoritings_count: 2,
comment_count: 0,
created_with: 
 { id: 124,
   kind: 'app',
   name: 'SoundCloud iOS',
   uri: 'http://api.soundcloud.com/apps/124',
   permalink_url: 'http://soundcloud.com/apps/iphone',
   external_url: 'http://itunes.com/app/soundcloud' },
attachments_uri: 'http://api.soundcloud.com/tracks/43622727/attachments' },
{ kind: 'track',
id: 119301,
created_at: '2009/01/21 18:50:00 +0000',
user_id: 62320,
duration: 158824,
commentable: true,
state: 'finished',
original_content_size: 2546372,
sharing: 'public',
tag_list: '',
permalink: 'the-fray-interview',
description: '',
streamable: true,
downloadable: true,
genre: '',
release: '',
purchase_url: null,
purchase_title: null,
label_id: null,
label_name: '',
isrc: '',
video_url: null,
track_type: '',
key_signature: '',
bpm: null,
title: 'The Fray interview',
release_year: null,
release_month: null,
release_day: null,
original_format: 'mp3',
license: 'all-rights-reserved',
uri: 'http://api.soundcloud.com/tracks/119301',
permalink_url: 'http://soundcloud.com/mattlissack/the-fray-interview',
artwork_url: null,
waveform_url: 'http://w1.sndcdn.com/1Ehu7uCn4vg6_m.png',
user: 
 { id: 62320,
   kind: 'user',
   permalink: 'mattlissack',
   username: 'mattlissack',
   uri: 'http://api.soundcloud.com/users/62320',
   permalink_url: 'http://soundcloud.com/mattlissack',
   avatar_url: 'http://a1.sndcdn.com/images/default_avatar_large.png?2262bae' },
stream_url: 'http://api.soundcloud.com/tracks/119301/stream',
download_url: 'http://api.soundcloud.com/tracks/119301/download',
playback_count: 613,
download_count: 5,
favoritings_count: 0,
comment_count: 0,
attachments_uri: 'http://api.soundcloud.com/tracks/119301/attachments' } ]

2 个答案:

答案 0 :(得分:2)

来自此处的文档:http://developers.soundcloud.com/docs/api/tracks 您可以使用 &order=created_at&order=hotness

答案 1 :(得分:1)

FYI https://developers.soundcloud.com/blog/removing-hotness-param

我不知道每个人仍然面临同样的问题,但我是,所以我在这里留下这篇文章:)