ComicVineApi
1.0.0
一個漂亮的 .NET API,封裝了很棒的 Comic Vine REST API。
您將需要來自 https://comicvine.com/api 的 API 金鑰。
尋找/取得資訊的主要方式有 3 種:
對於每個資源,您可以透過一行程式碼輕鬆請求特定項目:
// create the client
var client = new ComicVineClient ( " <API-KEY> " , " <CUSTOM-USER-AGENT> " ) ;
// request the Batgirl (Cassandra Cain) character
var cassie = await client . Character . GetAsync ( 65230 ) ;
// print something out
Console . WriteLine ( $" { cassie . Name } was born on { cassie . Birth } . " ) ;
基本過濾器的值:
// create the client
var client = new ComicVineClient ( " <API-KEY> " , " <CUSTOM-USER-AGENT> " ) ;
// request the female Cain family characters
var females = client . Character . Filter ( )
. WithValue ( x => x . Name , " Cain " )
. WithValue ( x => x . Gender , Gender . Female ) ;
// fetch the first result (all fields)
var first = await females . FirstOrDefaultAsync ( ) ;
// print something out
Console . WriteLine ( $" { first . Name } was born on { first . Birth } . " ) ;
使用減少的欄位過濾較小的有效負載:
// create the client
var client = new ComicVineClient ( " <API-KEY> " , " <CUSTOM-USER-AGENT> " ) ;
// request the female Cain family characters
var females = client . Character . Filter ( )
. WithValue ( x => x . Name , " Cain " )
. WithValue ( x => x . Gender , Gender . Female ) ;
// just fetch minimal data (id, name, birth)
var smallPayload = females
. IncludeField ( x => x . Id )
. IncludeField ( x => x . Name )
. IncludeField ( x => x . Birth ) ;
// fetch all the results on the page
var page = await smallPayload . ToListAsync ( ) ;
// fetch all the items on all the pages
foreach ( var character in page )
{
// print something out
Console . WriteLine ( $" { character . Name } was born on { character . Birth } . " ) ;
}
迭代伺服器上的所有結果(透過多個 API 呼叫):
// create the client
var client = new ComicVineClient ( " <API-KEY> " , " <CUSTOM-USER-AGENT> " ) ;
// request the female Cain family characters
var females = client . Character . Filter ( )
. WithValue ( x => x . Name , " Cain " )
. WithValue ( x => x . Gender , Gender . Female ) ;
// fetch all the items on all the pages
await foreach ( var character in filter . ToAsyncEnumerable ( ) )
{
// print something out
Console . WriteLine ( $" { character . Name } was born on { character . Birth } . " ) ;
}
TODO:新增文檔
TODO:新增文檔