Kotlin SDK for using the magicthegathering.io APIs.
Note that API use is free and does not require authentication or registration, but some rate limits apply. Read the official API website for more information.
Bintray JCenter | Build Status |
---|---|
Add the dependency to your project and you're good to go!
First of all, be sure you have the jcenter repository included in the build.gradle
file in the root of your project.
repositories {
jcenter()
}
Next add the gradle compile dependency to the build.gradle
file of your app module.
compile 'io.magicthegathering:kotlinsdk:1.0.3'
- Kotlin 1.0.6 or higher
val observable: Observable<List<MtgCard>> = MtgCardApiClient.getAllCardsObservable()
observable.subscribe { cards: List<MtgCard> ->
...
}
val cardsResponse: Response<List<MtgCard>> = MtgCardApiClient.getAllCards()
val cards = cardsResponse.body()
val observable: Observable<List<MtgCard>> = MtgCardApiClient.getAllCardsBySetCodeObservable("DOM")
observable.subscribe { cards: List<MtgCard> ->
...
}
val cardsResponse: Response<List<MtgCard>> = MtgCardApiClient.getAllCardsBySetCode("DOM")
val cards = cardsResponse.body()
val observable: Observable<List<MtgCard>> = MtgCardApiClient.getAllCardsObservable(50)
observable.subscribe { cards: List<MtgCard> ->
...
}
val cardsResponse: Response<List<MtgCard>> = MtgCardApiClient.getAllCards(50)
val cards = cardsResponse.body()
val observable: Observable<List<MtgCard>> = MtgCardApiClient.getAllCardsBySetCodeObservable("DOM", 50)
observable.subscribe { cards: List<MtgCard> ->
...
}
val cardsResponse: Response<List<MtgCard>> = MtgCardApiClient.getAllCardsBySetCode("DOM", 50)
val cards = cardsResponse.body()
val multiverseId: Int = 409741
val observable: Observable<MtgCard> = MtgCardApiClient.getCardObservable(multiverseId)
observable.subscribe { card: MtgCard ->
...
}
val multiverseId: Int = 409741
val cardResponse: Response<MtgCard> = MtgCardApiClient.getCard(multiverseId)
val card = cardResponse.body()
val partialName: String = "jace"
val pageSize: Int = 2
val page: Int = 1
val observable: Observable<List<MtgCard>> = MtgCardApiClient.getCardsByPartialNameObservable(partialName, pageSize, page)
observable.subscribe { cards: List<MtgCard> ->
...
}
val partialName: String = "jace"
val pageSize: Int = 2
val page: Int = 1
val cardsResponse: Response<List<MtgCard>> = MtgCardApiClient.getCardsByPartialName(partialName, pageSize, page)
val cards = cardsResponse.body()
val exactName: String = "zurgo helmsmasher"
val pageSize: Int = 2
val page: Int = 1
val observable: Observable<List<MtgCard>> = MtgCardApiClient.getCardsByExactNameObservable(exactName, pageSize, page)
observable.subscribe { cards: List<MtgCard> ->
...
}
val exactName: String = "zurgo helmsmasher"
val pageSize: Int = 2
val page: Int = 1
val cardsResponse: Response<List<MtgCard>> = MtgCardApiClient.getCardsByExactName(exactName, pageSize, page)
val cards = cardsResponse.body()
val language: String = "spanish"
val partialName: String = "jace"
val pageSize: Int = 2
val page: Int = 1
val observable: Observable<List<MtgCard>> = MtgCardApiClient.getCardsByPartialNameWithNonEnglishLanguageObservable(language, partialName, pageSize, page)
observable.subscribe { cards: List<MtgCard> ->
...
}
val language: String = "spanish"
val partialName: String = "jace"
val pageSize: Int = 2
val page: Int = 1
val cardsResponse: Response<List<MtgCard>> = MtgCardApiClient.getCardsByPartialNameWithNonEnglishLanguage(language, partialName, pageSize, page)
val cards = cardsResponse.body()
val language: String = "spanish"
val exactName: String = "zurgo aplastacráneos"
val pageSize: Int = 2
val page: Int = 1
val observable: Observable<List<MtgCard>> = MtgCardApiClient.getCardsByExactNameWithNonEnglishLanguageObservable(language, exactName, pageSize, page)
observable.subscribe { cards: List<MtgCard> ->
...
}
val language: String = "spanish"
val exactName: String = "zurgo aplastacráneos"
val pageSize: Int = 2
val page: Int = 1
val cardsResponse: Response<List<MtgCard>> = MtgCardApiClient.getCardsByExactNameWithNonEnglishLanguage(languageø, exactName, pageSize, page)
val cards = cardsResponse.body()
val observable: Observable<List<MtgSet>> = MtgSetApiClient.getAllSetsObservable()
observable.subscribe { sets ->
...
}
val setsResponse: Response<List<MtgSet>> = MtgSetApiClient.getAllSets()
val sets = setsResponse.body()
val setCode: String = "mm2"
val observable: Observable<MtgSet> = MtgSetApiClient.getSpecificSetObservable(setCode)
observable.subscribe { set ->
...
}
val setCode: String = "mm2"
val setResponse: Response<MtgSet> = MtgSetApiClient.getSpecificSet(setCode)
val set = setResponse.body()
val setCode: String = "mm2"
val observable: Observable<List<MtgCard>> = MtgSetApiClient.generateBoosterPackBySetCodeObservable(setCode)
observable.subscribe { cards ->
...
}
val setCode: String = "mm2"
val cardsResponse: Response<List<MtgCard>> = MtgSetApiClient.generateBoosterPackBySetCode(setCode)
val cards = cardsResponse.body()
val observable: Observable<List<String>> = MtgCardTypesApiClient.getAllTypesObservable()
observable.subscribe { cardTypes ->
...
}
val cardTypesResponse: Response<List<String>> = MtgCardTypesApiClient.getAllTypes()
val cardTypes = cardTypesResponse.body()
val observable: Observable<List<String>> = MtgCardTypesApiClient.getAllSupertypesObservable()
observable.subscribe { cardTypes ->
...
}
val cardTypesResponse: Response<List<String>> = MtgCardTypesApiClient.getAllSupertypes()
val cardTypes = cardTypesResponse.body()
val observable: Observable<List<String>> = MtgCardTypesApiClient.getAllSubtypesObservable()
observable.subscribe { cardTypes ->
...
}
val cardTypesResponse: Response<List<String>> = MtgCardTypesApiClient.getAllSubtypes()
val cardTypes = cardTypesResponse.body()
val observable: Observable<List<String>> = MtgFormatsApiClient.getAllFormatsObservable()
observable.subscribe { formats ->
...
}
val formatsResponse: Response<List<String>> = MtgFormatsApiClient.getAllFormats()
val formats = formatsResponse.body()