zenw0lf

zenw0lf

Building a JSON API in Elixir with Phoenix 1.5+

Hello all!

For those wanting to try your hands at Elixir / Phoenix, I wrote a comprehensive tutorial on doing a simple JSON API with said technologies.

Touches on everything: From language installation, app creation, schemas and endpoints, CORS configuration, simple authentication, to sessions (with cookies) and a bit of testing.

I updated it to latest Phoenix version:
Building a JSON API in Elixir with Phoenix 1.5+

Updated link: Build a JSON API with Phoenix - lobo_tuerto's notes

Any feedback is appreciated!

Most Liked

zenw0lf

zenw0lf

I’m thinking about writing one about building a basic GraphQL API with Phoenix and Absinthe in Elixir.
Could also touch on writing a frontend for it using Vue.js + Apollo.

Let me know if this sounds interesting to you people.

19
Post #5
jswny

jswny

Great tutorial! I really appreciate your style of tutorial (I can tell you have thought it through from the introduction)! I’m glad that you went through a bit of testing, which is often neglected these days. Even including things like custom 500 error pages is really nice because these are the things people just glaze over in their tutorials.

I am actually about to start a project where I need to setup Phoenix for a JSON API and I have been wondering about how to do authentication (JWT, API keys, etc.). I’m really glad I came across your tutorial since the session based method that you use seems the most simple and straight forward to me, and it’s in line with much of the authentication I’ve done in the past for Phoenix apps with interfaces.

Thanks again, great work and I really like your blog as well :slight_smile:

ibarch

ibarch

Just FYI, there is a nice book about writing Battleship game using Elixir and Phoenix Channels. The game in the book is called Islands, but it’s the same thing. You would better pick a unique game to attract more readers.

Nullstrike

Nullstrike

Vue.js + apollo would be great.

jung-hunsoo

jung-hunsoo

Looking forward to seeing GraphQL + Absinthe!

Where Next?

Popular in Guides/Tuts Top

zazaian
I recently generated the boilerplate for a new mix app using the Phoenix 1.3.1 phx.new generator and realized that the structure of the w...
New
zachallaun
Hey friends, wanted to share a tiny shell script I’ve been using to start Livebook with easy access to either a running production server...
New
tomciopp
TLS 1.3 has been out for a little over a year now, but it has been unavailable in Phoenix due to erlang’s handling of ssl. With the most ...
New
mhanberg
Hi! I recently finished adding authentication to my Phoenix API, so I wanted to share what I learned. I haven't created authentication ...
New
AstonJ
This was originally posted on my blog, but since my I’ve taken it down (I hadn’t posted anything on it for a while and since it was runni...
New
thetechnologyvault
One of our team members just published this getting started guide for Elixir/Phoenix devs to use the Nanobox platform: https://content.n...
New
Zurga
In a quest to optimize the amount of data sent between the server and client I recently decided to try to use MessagePack instead of JSON...
New
pinksynth
Whenever tests have to interact with an Ecto.Repo, sometimes it’s necessary to test a few different branches or paths that data can take....
New
ben-pr-p
Hey all! I put together a starter-pack / instructions to set up Phoenix with the new parcel-bundler instead of brunch (or webpack). It’s...
New
anuragg
We just published a guide to automatic clustering in Elixir 1.9, with Mix releases and libcluster. The cluster automatically discovers n...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New

We're in Beta

About us Mission Statement