a simple swift client to easily work with xivapi
- Xcode -> File -> Add Package Dependency
- paste this repository url:
https://github.com/Eisenhuth/xivapi-swift.git - Add Package
//option 1 - latest schema, latest version - unverified
let client = xivapiClient() //option 2 - providing your own schema/version
let schema = "exdschema@9942dd96c70dfbba55bbc4280da144e5cb410737-2024.11.06.0000.0000"
let client = xivapiClient(schema: schema, version: "7.15")//option 3 - using the schema/version this version of the package was verified against
let client = xivapiClient(automaticallyPin: true)Tip
It is highly recommended to specify a version and schema - alternatively use the automatic pin mentioned above to use the schema/version the package was verified against.
let item = await client.getItem(39727) //Grade 8 Tincture of Strength
let itemMinimal = await client.getItemMinimal(39727) //only contains Name, Description, Icon
let recipe = await client.getRecipe(35585) //Recipe: Grade 8 Tincture of Strength
let map = await client.getMap(696) //Thavnair
let trait = await client.getTrait(422) //Enhanced Unmend
let action = await client.getAction(7393) //The Blackest Nightthere are extensions for a lot of the data, e.g. Map has .mapPath to get the texture path, or TripleTriadCard's .imagePath to get the path to the card's artwork. I recommend not looking too closely at how specifically these paths are constructed, that way lies madness.
you can provide your own Codable structs for use with .getSheet
struct MyCustomItemStruct: Codable {
let row_id: Int
}let myItem = await client.getSheet(.Item, id: 39727) as MyCustomItemStruct?let myItem = await client.getSheet(name: "Item", id: 39727) as MyCustomItemStruct?or use the built-in structs
let ttCard = await client.getSheet(.TripleTriadCard, id: 346) as TripleTriadCard?
print(ttCard?.fields.Name ?? "name") //Zenos Galvus
print(ttCard?.fields.Description ?? "description") //“Did you find...fulfillment?”if let recipeId = await client.getItemRecipes(itemId: 39727)?.first {
let recipe = await client.getRecipe(recipeId)
recipe?.ingredients.forEach {
print("\($0.itemId) x\($0.amount)")
}
}
let entireLookup = await client.getItemRecipeDict() //[ItemId : [RecipeId]]