code

code

Building an API

I want to transfer an API that was built using fastapi in python to elixir. Should I use phoenix or plug? Phoenix is excellent for web development, but is it overkill for an API that serves another frontend built in js? plug on the other hand seems suitable from what I’ve read but I also read that it needs more boilerplate. The API is fairly complex and plug seems suitable to me. I just wanted to know if there is anything that I should be warned about regarding plug and if there are some tweaks to phoenix to make it similar to fastapi (ie: remove the fullstack web development packages).

Thank you.

Marked As Solved

RudManusachi

RudManusachi

Take a look at the API-only applications section of Phoenix docs.

Also Liked

victorbjorklund

victorbjorklund

I would say go with Phoenix unless it is a very simple API that won’t grow in the future (which does not seem to be the case). The overhead of phoenix is negligible but makes many things easier.

Just exclude everything you don’t need:

mix phx.new my_api --no-assets --no-gettext --no-html --no-mailer

code

code

Thank you

dimitarvp

dimitarvp

Phoenix, while making your app have a little more files, is much more future-proof than any almost barebones Plug app you might do.

Go for Phoenix. It might be slightly annoying to begin with but will very quickly pay dividends.

lud

lud

I’d go with Phoenix too. We build our APIs with it and it has been great so far.

The Phoenix tutorial will have you install the phx.new command. Once done, call mix help phx.new in your terminal and you will see options to disable HTML, LiveView, Tailwind and ESBuild when creating a new Phoenix project.

Where Next?

Popular in Questions Top

bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New

Other popular topics Top

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
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
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
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement