DEV Community

Dylan Anthony
Dylan Anthony

Posted on

The best way to make a web API

What’s your favorite way to make a web API? Give us an outline:

  • Programming Language
  • Framework
  • Scheme/spec/standard
  • Documentation
  • Authentication
  • Authorization
  • Client libraries?

Here’s my example:

  • Python
  • Flask
  • OpenAPI REST (I use Flask-RESTPlus)
  • Swagger UI
  • JWT (Bearer token) with Flask-Login
  • Resource-based policies with Flask-Pundit
  • Swagger codegen

There are a lot of decisions to make when creating an API, and a lot of problems that don’t seem to have a standard solution. So what’s yours?

Top comments (16)

Collapse
 
nelsonblack profile image
Nelson Bwogora

Programming languave typescript
Framework :Nestjs framework
API : (inbuilt)Nestjs graphql package(Apollo)
Documentation: (inbuilt) graphql playground
ORM: nestjs-typeorm package

Graphql rocks since trying it out I have rarely ever gone back to REST

Collapse
 
dbanty profile image
Dylan Anthony

Oooo a GraphQL answer with TypeScript! I’ve been wanting to try this sort of solution and tried (and failed) to do so with Node (express I think).

Do you have a recommended tutorial / example / anything I could get started with trying NestJS?

Collapse
 
nelsonblack profile image
Nelson Bwogora

There is this example here github.com/nestjs/nest/tree/master... will make a git of nest js , graphpl MySQL simple crud and share it

Collapse
 
andreykorchak profile image
Andrey Korchak • Edited

I'm in love with GraphQL so I'm currently using this approach instead of traditional REST APIs.

  • Python (with async features and co-routines)
  • Starlette, an async Python framework with great GraphQL support.
  • GraphQL
  • Starlette comes with GraphiQl which is a great tool for API testing and documenting.
  • Starlette middlewares are providing a pretty decent solutions for all Authentication/Authorization tasks
  • Since I'm focused on GraphQl I'll go with React + Apollo on client side.
Collapse
 
dbanty profile image
Dylan Anthony

I haven’t heard of Starlette, I’ll take a look. Thanks!

Collapse
 
nathanenglert profile image
Nathan Englert
  • C#
  • .NET Core WebAPI
  • REST
  • Postman for documentation and testing
Collapse
 
dbanty profile image
Dylan Anthony

I keep wanting to try out C#, but that requires me to spend time on Windows which I barely use 🙃.

Does .NET have a good way of exporting stuff to Postman or do you have to write your docs / tests independently of your code?

Collapse
 
dschumann profile image
dschumann

Cool thing is .Net Core doesn't run only on Windows.

Thread Thread
 
nathanenglert profile image
Nathan Englert

This! 👆👆

I do all of my C#.NET development on a Mac.

As for exporting from .NET to Postman though, I actually work the other way around. I try to define the APIs first with their request data, possible responses, etc. You can then generate server / client code from there. However, I do typically write the two separately still.

Thread Thread
 
dbanty profile image
Dylan Anthony

Right on, I’ll definitely try out C# then from the confort of my home OS :). Do you have a recommended starting point? Meaning a favorite tutorial or book or website?

Collapse
 
anwar_nairi profile image
Anwar

Programming Language: PHP
Framework: Laravel
Scheme/spec/standard: JUR
Documentation: dunno
Authentication: firebase/jwt-php + Crypt::encrypt Laravel's facade
Authorization: Laravel's Gate
Client libraries: dunno

Collapse
 
dbanty profile image
Dylan Anthony

Thanks! I’ve only done a teeny tiny bit of PHP but it still rules the internet by usage. Glad to hear they have a framework which handles authorization for you.

I have used firebase for authentication from Go, it’s very easy and I strongly recommend it to anyone over doing your own password storage/hashing.

Collapse
 
anwar_nairi profile image
Anwar

I share your pov, I prefer firebase authentication over Laravel passeport mostly because I like to integrate it in my client, so I do least server side code possible, yet Laravel make me earn so much time :)

Collapse
 
tomebuljevic profile image
Tomislav Buljević

Well, I am a Symfony dev so here goes:

  • PHP
  • Symfony
  • JSONAPI docs
  • Apicurio
  • JWT
  • Authorization: Symfony Guard
Collapse
 
dbanty profile image
Dylan Anthony

Another PHP framework which handles authorization, nice! Maybe it’s just Flask that doesn’t have a standard method 😅.

Haven’t done anything with JSONAPI, I’ll have to check it out.

Collapse
 
george53005 profile image
George53005 • Edited

I found this neat tool where I don't need to write any code:
Instantwebapi.com
It generates the code for web API and unit tests!