Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 90 lines (58 sloc) 2.397 kB
718b40f @fxb Initial commit.
authored
1 JavaScript last.fm API Readme
2 -----------------------------
3
4 Overview
5 --------
6
7 The JavaScript last.fm API allows you to call last.fm API methods and get the
8 corresponding JSON responses. Basically it just acts as a wrapper that gives
9 easy access to API methods. Responses can be cached using the localStorage API.
10
11
12 Encoding
13 --------
14
15 You don't need to worry about encoding when calling API methods. Everything
16 should automatically be UTF-8 encoded and decoded by your browser if you set
17 the Content-Type for your document to UTF-8:
18
19 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
20
21
22 Authentication
23 --------------
24
25 It's easy to fetch a session for a user account. This allows you to perform
26 actions on that account in a manner that is secure for last.fm users. All
27 write services require authentication.
28
29
30 Write methods
31 -------------
32
33 Due to technical restrictions it's not possible to get a response when calling
34 write methods. Reading responses is only possible using HTTP Access-Control,
35 which is currently not supported by the last.fm API.
36
37
38 Submissions
39 -----------
40
41 Scrobbling is not yet supported.
42
43
44 Usage
45 -----
46
47 You need to add the following scripts to your code in order to work with the
48 JavaScript last.fm API:
49
50 <script type="text/javascript" src="lastfm.api.md5.js"></script>
51 <script type="text/javascript" src="lastfm.api.js"></script>
52
53 If you want to use caching, you need to add another script:
54
55 <script type="text/javascript" src="lastfm.api.cache.js"></script>
56
57 Built in JSON support should be available in modern browsers, if you want to
8be684e @fxb Update API to reflect current last.fm API.
authored
58 be sure it's supported, include the following:
718b40f @fxb Initial commit.
authored
59
8be684e @fxb Update API to reflect current last.fm API.
authored
60 <script type="text/javascript" src="json2.js"></script>
61
62 You can get that file at http://www.json.org/json2.js , and make sure you've
63 removed the first line before using it.
718b40f @fxb Initial commit.
authored
64
65 Now you can use the JavaScript last.fm API like this:
66
67 /* Create a cache object */
68 var cache = new LastFMCache();
69
70 /* Create a LastFM object */
71 var lastfm = new LastFM({
72 apiKey : 'f21088bf9097b49ad4e7f487abab981e',
73 apiSecret : '7ccaec2093e33cded282ec7bc81c6fca',
74 cache : cache
75 });
76
77 /* Load some artist info. */
78 lastfm.artist.getInfo({artist: 'The xx'}, {success: function(data){
79 /* Use data. */
80 }, error: function(code, message){
81 /* Show error message. */
82 }});
83
84
85 More
86 ----
87
88 For further information, please visit the official API documentation:
89 http://www.last.fm/api
Something went wrong with that request. Please try again.