Skip to content

Instantly share code, notes, and snippets.

How to build a JSON API with Elixir & Phoenix

Welcome! In this guide we'll go step by step to build an API with Elixir and the Phoenix Framework.

Note, i wrote this around 2017/18 so things might have changed. Also it's incomplete. Hopefully still useful. Yadayada.

Here's the plan:

  • Install Elixir
  • Create a new Phoenix project
defmodule App do
use GenServer
def start_link([]) do
GenServer.start_link(__MODULE__, [])
end
def init(state) do
{:ok, state}
end

Basic transition

HTML

<div></div>

CSS

# Routify & Svelte

Sever Side s Client Side Rendering

Server side

Client side

Svelte Notes

Built in web server

Go to directory of project

php -S localhost:8000

Parts of a Class

The class name

The attributes (properties of the class). The properties have this format:

-name: string
-age: int
-id: -int

Parts of a Class

The class name

The attributes (properties of the class). The properties have this format:

-name: string
-age: int
-id: -int
# Parts of a Class
The class name
The attributes (properties of the class). The properties have this format:
```
-name: string
-age: int
-id: -int