IF.Lastfm/README.md

114 lines
3.7 KiB
Markdown
Raw Permalink Normal View History

2015-05-19 13:32:05 +01:00
# Inflatable Last.fm .NET SDK
2016-12-05 02:57:46 +00:00
![Project logo](./res/if-lastfm-logo-300.png)
2020-06-28 01:17:53 +01:00
[![Code licence](https://img.shields.io/badge/licence-MIT-blue.svg?style=flat)](LICENCE.md)
2016-12-05 02:57:46 +00:00
2021-05-18 12:00:50 +01:00
## Maintenence help wanted
Hi there! The maintainer of this library @rikkit is now mostly a TypeScript + React dev, and has been for the last several years. Since this is a .Net library, the maintainer will probably not be able to keep it up-to-date to the latest .Net standards. If you spot something wrong, please file and issue or better yet, a pull request. Thanks!
2015-05-19 13:32:05 +01:00
## Project Goals
2013-07-01 15:36:58 +01:00
2015-05-19 13:32:05 +01:00
- To provide complete .NET bindings for the Last.fm REST API
- To build useful components for Last.fm applications
- To be the very best, like no-one ever was
2013-07-01 15:36:58 +01:00
2015-05-19 13:32:05 +01:00
## Contributing
2014-11-04 14:38:06 +00:00
2015-05-19 13:32:05 +01:00
Input is always welcome! [Raise an issue on GitHub](https://github.com/inflatablefriends/lastfm/issues), or send a message to [the Gitter chatroom](https://gitter.im/inflatablefriends/lastfm) if you need help with the library.
2014-11-04 14:38:06 +00:00
2015-05-19 13:32:05 +01:00
If you're interested in contributing code or documentation, [this short introduction to the library](doc/contributing.md) will help you get started.
2013-07-01 15:36:58 +01:00
## Quickstart
2015-04-26 19:16:06 +01:00
2020-06-28 01:17:53 +01:00
### Installing
2014-11-04 14:38:06 +00:00
2020-06-28 01:17:53 +01:00
#### NuGet
2014-11-04 14:38:06 +00:00
2020-06-28 01:17:53 +01:00
Install [Inflatable.Lastfm](
https://www.nuget.org/packages/Inflatable.Lastfm/) from NuGet.
2015-04-26 19:16:06 +01:00
#### NuGet - prerelease code
2014-11-04 14:38:06 +00:00
2020-06-28 01:17:53 +01:00
1. Install the [.NET Core SDK](https://docs.microsoft.com/en-us/dotnet/core/install/sdk)
2. Clone this repo and checkout to the commit you need
3. Run `dotnet pack`
4. Reference the built NuGet package file in your project
2014-11-04 14:38:06 +00:00
2020-06-28 01:17:53 +01:00
### Examples
2014-11-04 14:38:06 +00:00
2015-04-26 19:16:06 +01:00
First, [sign up for Last.fm API](http://last.fm/api) access if you haven't already.
2014-11-04 14:38:06 +00:00
2015-04-26 19:16:06 +01:00
Create a LastfmClient:
2014-11-04 14:38:06 +00:00
```c#
2015-04-26 19:16:06 +01:00
var client = new LastfmClient("apikey", "apisecret");
2014-11-04 14:38:06 +00:00
```
2015-04-26 19:16:06 +01:00
Get information about an album:
2013-07-01 15:36:58 +01:00
2014-10-15 21:06:37 +01:00
```c#
2018-05-23 17:45:00 +01:00
var response = await client.Album.GetInfoAsync("Grimes", "Visions");
2014-11-04 14:38:06 +00:00
2015-04-26 19:16:06 +01:00
LastAlbum visions = response.Content;
2014-11-04 14:38:06 +00:00
```
2015-05-19 13:32:05 +01:00
For methods that return several items, you can iterate over the response:
2014-11-04 14:38:06 +00:00
```c#
2015-04-26 19:16:06 +01:00
var pageResponse = await client.Artist.GetTopTracksAsync("Ben Frost", page: 5, itemsPerPage: 100);
2014-11-04 14:38:06 +00:00
2015-04-26 19:16:06 +01:00
var trackNames = pageResponse.Select(track => track.Name);
```
2015-04-26 19:16:06 +01:00
Several API methods require user authentication. Once you have your user's Last.fm username and password, you can authenticate your instance of LastfmClient:
```c#
var response = await client.Auth.GetSessionTokenAsync("username", "pass");
// or load an existing session
UserSession cachedSession;
var succesful = client.Auth.LoadSession(cachedSession);
```
2013-07-01 15:36:58 +01:00
2015-04-26 19:16:06 +01:00
Authenticated methods then work like any other
2014-10-15 21:06:37 +01:00
2015-04-26 19:16:06 +01:00
```c#
if (client.Auth.HasAuthenticated) {
var response = await client.Track.LoveAsync("Ibi Dreams of Pavement (A Better Day)", "Broken Social Scene");
}
```
2014-10-15 21:06:37 +01:00
2015-04-05 00:46:02 +01:00
## Documentation
2014-11-04 14:38:06 +00:00
2015-04-05 00:46:02 +01:00
- [Api method progress report](PROGRESS.md)
2015-05-19 13:32:05 +01:00
- [Contributing](doc/contributing.md)
2015-04-05 00:46:02 +01:00
- [Scrobbling](doc/scrobbling.md)
- [Dependency Injection](doc/dependency-injection.md)
2015-05-19 13:32:05 +01:00
- [Example Windows Phone app](https://github.com/inflatablefriends/lastfm-samples)
2014-10-15 21:06:37 +01:00
## Platform Compatibility
2018-07-01 19:58:57 +01:00
The main package targets ```netstandard1.1```. Development is on the ```master``` branch.
2018-07-01 19:58:57 +01:00
### Dependencies
- Newtonsoft.Json 9.0.1 =<
- System.Net.Http 4.3.0 =<
2018-07-01 19:58:57 +01:00
### Supported platforms
Check [this table](https://docs.microsoft.com/en-us/dotnet/articles/standard/library#net-platforms-support) for supported platforms.
2018-07-01 19:58:57 +01:00
### Other platforms
2014-10-15 21:06:37 +01:00
2018-07-01 19:58:57 +01:00
If you need support for a .NET platform that doesn't support .Net Standard 1.1, first see if the feature you need is available in v0.3 or earlier - that version targeted PCL profile 259, and so is compatible with e.g. Windows 8.0 and Windows Phone 7.
2014-10-15 21:06:37 +01:00
2018-07-01 19:58:57 +01:00
If you need a feature for these older platforms, please raise an issue.
2015-04-26 19:16:06 +01:00
## Credits
Maintained by [@rikkilt](http://twitter.com/rikkilt).
2015-05-19 13:32:05 +01:00
Thanks to [all contributors](https://github.com/inflatablefriends/lastfm/graphs/contributors)!