Updated Docs (still WIP)

This commit is contained in:
Johnny Dellinger @PC 2015-07-09 12:46:30 +02:00
parent 473e7040d3
commit 077e611d05
13 changed files with 352 additions and 16 deletions

View File

@ -0,0 +1,53 @@
##GetAlbumTracks
> Get Spotify catalog information about an album's tracks. Optional parameters can be used to limit the number of tracks returned.
**Paramters**
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|id| The Spotify ID for the album. | EXAMPLE
|limit| The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50. | EXAMPLE
|offset| The index of the first track to return. Default: 0 (the first object). | EXAMPLE
|market| An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. | EXAMPLE
Returns a [Public User Model](https://developer.spotify.com/web-api/object-model/#user-object-public)
**Usage**
```csharp
```
---
##GetAlbum
> Get Spotify catalog information for a single album.
**Paramters**
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|id| The Spotify ID for the album. | EXAMPLE
|market| An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. | EXAMPLE
Returns a [Public User Model](https://developer.spotify.com/web-api/object-model/#user-object-public)
**Usage**
```csharp
```
---
##GetSeveralAlbums
> Get Spotify catalog information for multiple albums identified by their Spotify IDs.
**Paramters**
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|ids| A list of the Spotify IDs for the albums. Maximum: 20 IDs. | EXAMPLE
|market| An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. | EXAMPLE
Returns a [Public User Model](https://developer.spotify.com/web-api/object-model/#user-object-public)
**Usage**
```csharp
```
---

View File

@ -0,0 +1,85 @@
##GetArtist
> Get Spotify catalog information for a single artist identified by their unique Spotify ID.
**Paramters**
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|id| The Spotify ID for the artist. | EXAMPLE
Returns a [Public User Model](https://developer.spotify.com/web-api/object-model/#user-object-public)
**Usage**
```csharp
```
---
##GetRelatedArtists
> Get Spotify catalog information about artists similar to a given artist. Similarity is based on analysis of the Spotify community's listening history.
**Paramters**
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|id| The Spotify ID for the artist. | EXAMPLE
Returns a [Public User Model](https://developer.spotify.com/web-api/object-model/#user-object-public)
**Usage**
```csharp
```
---
##GetArtistsTopTracks
> Get Spotify catalog information about an artist's top tracks by country.
**Paramters**
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|id| The Spotify ID for the artist. | EXAMPLE
|country| The country: an ISO 3166-1 alpha-2 country code. | EXAMPLE
Returns a [Public User Model](https://developer.spotify.com/web-api/object-model/#user-object-public)
**Usage**
```csharp
```
---
##GetArtistsAlbums
> Get Spotify catalog information about an artist's albums. Optional parameters can be specified in the query string to filter and sort the response.
**Paramters**
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|id| The Spotify ID for the artist. | EXAMPLE
|type| A list of keywords that will be used to filter the response. If not supplied, all album types will be returned | EXAMPLE
|limit| The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50. | EXAMPLE
|offset| The index of the first album to return. Default: 0 | EXAMPLE
|market| An ISO 3166-1 alpha-2 country code. Supply this parameter to limit the response to one particular geographical market | EXAMPLE
Returns a [Public User Model](https://developer.spotify.com/web-api/object-model/#user-object-public)
**Usage**
```csharp
```
---
##GetSeveralArtists
> Get Spotify catalog information for several artists based on their Spotify IDs.
**Paramters**
|Name|Description|Example|
|--------------|-------------------------|-------------------------|
|ids| A list of the Spotify IDs for the artists. Maximum: 50 IDs. | EXAMPLE
Returns a [Public User Model](https://developer.spotify.com/web-api/object-model/#user-object-public)
**Usage**
```csharp
```
---

161
docs/SpotifyWebApi/auth.md Normal file
View File

@ -0,0 +1,161 @@
#Auth-Methods
Before you can use the Web API full functional, you need the user to authenticate your Application.
If you want to know more, you can read to the whole auth-process [here](https://developer.spotify.com/web-api/authorization-guide/).
Before you start, you need to create a Application at Spotify: [Your Applications](https://developer.spotify.com/my-applications/#!/applications)
***
After you created your Application, you will have following important values:
>**Client_Id** This is your client_id, you don't have to hide it
>**Client_Secret** Never use this in one of your client-side apps!! Keep it secret!
>**Redirect URIs** Add "http://localhost", if you want full support for this API
Now you can start with the User-authentication, Spotify provides 3 ways:
* [ImplicitGrantAuth](/SpotifyWebApi/#implicitgrantauth) (**Recommended**, no server-side code needed)
* [AutorizationCodeAuth](/SpotifyWebApi/#implicitgrantauth) (Not Recommended, Server-side code needed, else it's unsecure)
* [ClientCredentialsAuth](/SpotifyWebApi/#implicitgrantauth) (Not Recommended, Server-side code needed, else it's unsecure)
**Note:** I would recommend a little PHP Script, which will exchange the Keys using AutorizationCodeAuth.
When using ImplicitGrantAuth, another user could abuse the "localhost" RedirectUri by creating a "fake"-app which uses your ClientId.
Overview:
![Overview](http://i.imgur.com/uf3ahTl.png)
After implementing one of the provided auth-methods, you can start doing requests with the token you get from one of the auth-methods
##ImplicitGrantAuth
This way is **recommended** and the only auth-process, which does not need a server-side exchange of keys. With this approach, you directly get a Token object after the user authed your application.
You won't be able to refresh the token. If you want to use the internal Http server, please add "http://localhost" to your application redirects.
More info: [here](https://developer.spotify.com/web-api/authorization-guide/#implicit_grant_flow)
```csharp
static ImplicitGrantAuth auth;
static void Main(string[] args)
{
//Create the auth object
auth = new ImplicitGrantAuth()
{
//Your client Id
ClientId = "XXXXXXXXXXXXXXXX",
//Set this to localhost if you want to use the built-in HTTP Server
RedirectUri = "http://localhost",
//How many permissions we need?
Scope = Scope.USER_READ_PRIVATE,
};
//Start the internal http server
auth.StartHttpServer();
//When we got our response
auth.OnResponseReceivedEvent += auth_OnResponseReceivedEvent;
//Start
auth.DoAuth();
}
static void auth_OnResponseReceivedEvent(Token token, string state, string error)
{
//stop the http server
auth.StopHttpServer();
var spotify = new SpotifyWebApiClass()
{
TokenType = token.TokenType,
AccessToken = token.AccessToken
};
//We can now make calls with the token object
}
```
##AutorizationCodeAuth
This way is **not recommended** and requires server-side code to run securely.
With this approach, you first get a code which you need to trade against the access-token.
In this exchange you need to provide your Client-Secret and because of that it's not recommended.
(But you can e.g exchange to codes via a PHP Script)
A good thing about this method: You can always refresh your token, without having the user to auth it again
More info: [here](https://developer.spotify.com/web-api/authorization-guide/#authorization_code_flow)
```csharp
static AutorizationCodeAuth auth;
static void Main(string[] args)
{
//Create the auth object
auth = new AutorizationCodeAuth()
{
//Your client Id
ClientId = "XXXXXXXXXXXXXXX",
//Set this to localhost if you want to use the built-in HTTP Server
RedirectUri = "http://localhost",
//How many permissions we need?
Scope = Scope.USER_READ_PRIVATE,
};
//This will be called, if the user cancled/accept the auth-request
auth.OnResponseReceivedEvent += auth_OnResponseReceivedEvent;
//a local HTTP Server will be started (Needed for the response)
auth.StartHttpServer();
//This will open the spotify auth-page. The user can decline/accept the request
auth.DoAuth();
Thread.Sleep(60000);
auth.StopHttpServer();
Console.WriteLine("Too long, didnt respond, exiting now...");
}
private static void auth_OnResponseReceivedEvent(AutorizationCodeAuthResponse response)
{
//Stop the HTTP Server, done.
auth.StopHttpServer();
//NEVER DO THIS! You would need to provide the ClientSecret.
//You would need to do it e.g via a PHP-Script.
Token token = auth.ExchangeAuthCode(response.Code, "XXXXXXXXXXX");
var spotify = new SpotifyWebApiClass()
{
TokenType = token.TokenType,
AccessToken = token.AccessToken
};
//With the token object, you can now make API calls
}
```
##ClientCredentialsAuth
This way is **not recommended** and requires server-side code to run securely.
With this approach, you make a POST Request with a base64 encoded string (consists of ClientId + ClientSecret). You will directly get the token (Without a local HTTP Server), but it will expire and can't be refreshed.
If you want to use it securely, you would need to do it all server-side.
**NOTE:** You will only be able to query non-user-related information e.g search for a Track.
More info: [here](https://developer.spotify.com/web-api/authorization-guide/#client_credentials_flow)
```csharp
static ClientCredentialsAuth auth;
static void Main(string[] args)
{
//Create the auth object
auth = new ClientCredentialsAuth()
{
//Your client Id
ClientId = "XXXXXXXXXXXXXXX",
//Your client secret UNSECURE!!
ClientSecret = "XXXXXXXXXXXX",
//How many permissions we need?
Scope = Scope.USER_READ_PRIVATE,
};
//With this token object, we now can make calls
Token token = auth.DoAuth();
var spotify = new SpotifyWebApiClass()
{
TokenType = token.TokenType,
AccessToken = token.AccessToken,
UseAuth = false
};
}
```

View File

View File

@ -0,0 +1,39 @@
#SpotifyWebAPI
This API provides full access to the new SpotifyWebAPI introduced [here](https://developer.spotify.com/web-api/).
With it, you can search for Tracks/Albums/Artists and also get User-based information.
It's also possible to create new playlists and add tracks to it.
---
#Getting started
The API features all currently available features and also provides some examples to get things rolling!
Full-Method Reference:
* [Albums](test)
[Examples](/SpotifyWebApi/examples)
---
#Properties
##UseAuth
Wether auth should be used or not. User-stuff can only be fetched with auth.
**NOTE:** If you use auth, you need to provide both, `TokenType` and `AccessToken`
```csharp
_spotify.UseAuth = false;
```
##TokenType
The token-type. Normally "Bearer" or "Basic".
```csharp
_spotify.TokenType = "XXXXXXXXXXXXXXXX";
```
##AccessToken
The access-token received by your auth-type.
```csharp
_spotify.AccessToken = "XXXXXXXXXXXXXXXX";
```

View File

@ -1,5 +0,0 @@
# WIP
```csharp
var test = new SpotifyApi();
```

View File

@ -1 +0,0 @@
# WIP

View File

@ -1,14 +1,18 @@
site_name: 'SpotifyAPI-NET'
theme: ''
theme_dir: 'mytheme'
pages:
- ['index.md', 'Home']
- ['about.md', 'About']
- ['SpotifyWebApi/index.md', 'SpotifyWebApi', 'About']
- ['SpotifyLocalApi/index.md', 'SpotifyLocalApi', 'About']
- ['SpotifyWebApi/gettingstarted.md', 'SpotifyWebApi', 'Getting started']
- ['SpotifyWebApi/examples.md', 'SpotifyWebApi', 'Examples']
- ['SpotifyWebApi/auth.md', 'SpotifyWebApi', 'Authentication']
- ['SpotifyWebApi/albums.md', 'SpotifyWebApi', '- Albums']
- ['SpotifyWebApi/artists.md', 'SpotifyWebApi', '- Artists']
- ['SpotifyLocalApi/index.md', 'SpotifyLocalApi', 'SpotifyLocalApi']
repo_url: 'https://github.com/JohnnyCrazy/SpotifyAPI-NET'
site_author: 'JohnnyCrazy'
site_description: 'API Docs for SpotifyAPI-NET'
extra_javascript:
- '//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/highlight.min.js'
- 'highlight.js'
markdown_extensions:
- sane_lists

View File

@ -16,7 +16,7 @@
<link href="{{ base_url }}/css/font-awesome-4.0.3.css" rel="stylesheet">
<link href="{{ base_url }}/css/prettify-1.0.css" rel="stylesheet">
<link href="{{ base_url }}/css/base.css" rel="stylesheet">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/monokai_sublime.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/styles/agate.min.css">
{%- for path in extra_css %}
<link href="{{ path }}" rel="stylesheet">
{%- endfor %}

File diff suppressed because one or more lines are too long

View File

@ -2,9 +2,9 @@
/* Prettyify */
$( document ).ready(function() {
hljs.initHighlightingOnLoad();
$('table').addClass('table table-striped table-hover');
});
/* Scrollspy */
var navHeight = $('.navbar').outerHeight(true) + 10

View File

@ -1,4 +1,4 @@
<div class="bs-sidebar hidden-print affix well" role="complementary">
<div class="bs-sidebar hidden-print affix well" role="complementary" style="height=90%;">
<ul class="nav bs-sidenav">
{% for toc_item in toc %}
<li class="main {% if toc_item.active %}active{% endif %}"><a href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>