# Julia API design

**URL:** <https://discourse.julialang.org/t/julia-api-design/65285>\
**Category:** General Usage\
**Created:** [July 26, 2021, 12:21am UTC](https://discourse.julialang.org/t/julia-api-design/65285 "2021-07-26T00:21:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![minetest2048](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/minetest2048/32/45961_2.png) [@minetest2048](https://discourse.julialang.org/u/minetest2048)\
**Post date:** [July 26, 2021, 12:21am UTC](https://discourse.julialang.org/t/julia-api-design/65285/1 "2021-07-26T00:21:53Z")

</div>

I want to try to reimplement [pyxivapi](https://github.com/xivapi/xivapi-py) in Julia, which is client for [XIVAPI](https://xivapi.com/) REST API. But I don’t know how to write the Julia APIs that looks like Julia library. Julia feels very different than other programming languages that I used. Is there a guide on how to design API for Julia?

Several more concrete questions:

Lets say I want to rewrite this code in Julia:

```julia
client = pyxivapi.XIVAPIClient(api_key="your_key_here")
item = client.index_by_id(
        index="Item", 
        content_id=23575, 
        columns=["ID", "Name", "Icon", "ItemUICategory.Name"], 
        language="de"
)

```

First question:  
Can I write the `index_by_id` in `client.index_by_id` style or `index_by_id(client,...)` better? For the second style, do `client` go first in the arguments, or it go in the last?

Second question:  
There is a `language` optional argument in that function. XIVAPI accepts `jp,en,de,fr`. I can implement it in Julia in several ways:

1. Keep it that way, use string comparison `language = "de"`

2. Use `:` instead, `Plots.jl` is like that `language = :de`

3. Define an enum and set `language` argument type as that enum

4. Make a `Language` abstract type, then make those languages as concrete type

Which one looks more Julian? Which one is faster? And which one can autocomplete in REPL or VS Code?

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [July 26, 2021, 12:26am UTC](https://discourse.julialang.org/t/julia-api-design/65285/2 "2021-07-26T00:26:16Z")

</div>

`index_by_id(client,...)` is what you want. I think the enum solution for language is probably best, but that’s less clear The symbol solution looks OK too.
