Building a JSON API in Elixir with Phoenix 1.4+

api
phoenix
json

#1

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.4+

Any feedback is appreciated!


Session doesn't persist across web requests
#2

Thanks! It’s a really nice tutorial.


#3

You are welcome! :slight_smile:


#4

I’ve also bookmarked it :003: (will go thro it when I’ve finished reading Programming Phoenix)

Thanks - we could definitely do with more tuts like this :023:


#5

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.


#6

I’d be interested an updated GraphQL tutorial.


#7

I’d be interested in one for…

  • LiveView (when it’s out :lol:)
  • Drab
  • Texas

(can you tell I’d like to minimise JS!)

And then perhaps:

  • Vue.js
  • and maybe Bucklescript or Elm

You could start a poll btw “What kind of tutorial would you like to see?” and see what kind of response you get :003:


#8

Vue.js + apollo would be great.


#9

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:


#10

Ok, I’ve thinking about the poll idea, and here is the stuff I’ve come up with:

  • GraphQL API (Phoenix + Absinthe)
  • Static site generator (markdown + frontmatter => HTML)
  • Simple game server (Phoenix) + Game client (Vue.js)

0 voters

Those are the 3 things I’ve been wanting to dabble in, and plan to get a tutorial out of them.

For the GraphQL API one, it’d be similar to the JSON API one, but you’ll have GraphQL endpoints ready for use with something like vue-apollo.

For the static site generator, I’m currently working on one, the idea is to use it for my own blog to replace Hugo , since I can’t really stand its templating language :smile:

And as for the game server, probably will go for a multiplayer Battleship game using Phoenix and WebSockets.

Let me know what y’all think. Thx.


#11

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.


#12

Thanks for the heads up!
All right, maybe multiplayer Tetris or something? :smile:


#13

Looks like a solid advantage on the GraphQL one.
I’ll close the poll after the weekend.


#14

Thanks everyone for your participation!

So, I’ll be working on a GraphQL API tutorial over the coming weeks on my spare time.
Once it’s done I’ll post a link on this forum to get some feedback.


#15

Congrats!