DEV Community

Pierre Bouillon
Pierre Bouillon

Posted on

Minimal API in c

Hi !

I recently started to explore the possibilities of creating my own API and so far, it is pretty much simple in Python and C#; that's why I wanted to dive a little deeper in it and try to create my own in C.

The problem is that it seems that I can't find any accessible and minimalist implementation of an API in C (with its basic concepts, such as socket for example).

Could anyone show me / link me a resource that would explain me how to do a small hello world for example (as flask does) ?

Thank you !

Top comments (10)

Collapse
 
grantstromgren profile image
Grant Stromgren

I ended up going with a C# API in one of my projects, more so out of it's ease of authentication/authorization with Active Directory.

I found the .NET Web API framework really easy to use, but as Meghan mentioned, nothing is too "minimal" around here.

Collapse
 
fquinner profile image
fquinner

Does it need to use socket? Even for C programming, writing an API using sockets can soon become non-portable and painful. I'd suggest using something like mongoose for C or Poco if you can stretch to C++ (the "other" poco if you're coming from C# ;)). The poco project has a hello world style web app example right on it's home page.

Collapse
 
pbouillon profile image
Pierre Bouillon

I would absolutely love to. Unfortunately it seems that "try it the way we teach it" instead of "do it in the most elegant way or with the most relevant tools" is not a very common practice in CS here 😭

Collapse
 
pbouillon profile image
Pierre Bouillon

Thank you so much !

I will build my researches around this, thank you for your time !!

Collapse
 
nektro profile image
Meghan (she/her)

Nothing in C is minimalist.

Collapse
 
pbouillon profile image
Pierre Bouillon

True ahah

Collapse
 
pbouillon profile image
Pierre Bouillon

I will give it a look, thanks !

Collapse
 
joruch profile image
Joris

This is maybe a little of topic. But Ms build a really powerful rest framework in cpp. Maybe you can draw some inspiration from there