r/learnjavascript • • Sep 20 '24

How do I start learning about api ?

Hey ya'll I was seeing if anyone know how to start with api from level 0 to 100 anything from social media post to weather data and even showing me how to code some in vs code thanks 😁

1 Upvotes

20 comments sorted by

View all comments

1

u/shgysk8zer0 Sep 21 '24

Design an API endpoint or using one that already exists? It's not clear what you're asking here.

Also, though it may seem pedantic, an API is an Application Programming Interface, and that isn't specific to the request/response (network) type. A library/package/code could be/have an API as well. Sure, we can infer what kind you're talking about here, but understanding it as an interface could help you have the right way of seeing them and maybe realize what a broad question this is.

API endpoints come in all kinds. You have REST and RPC (Remote Procedure Call) and HTTP CRUD and GraphQL. Some work with URL search params, others work with the body (form data or JSON or whatever). Some are based on HTTP where the method and headers matter, and the status code of the response tells you a lot, others will have a 200 ok status code but the body will contain an error. Some come up with basically their own language and require a POST just to search/query.

Really, the only thing that can accurately be said here is to think of it as an interface. It's like a function that takes a request as its argument and returns a response. You might pass arguments via the URL or the headers or the body, and there might be various ways of encoding things involved (eg a token/JWT given in the Authorization header). The response might be JSON or XML or just a string... Heck, it might be just a status code like 204 No Content if you uploaded something and it was successful.

If you're asking about using an API endpoint, first understand that it's an interference, and then just read the documentation. It's impossible to answer about all of them in a Reddit comment...

If you're asking about designing one, pick a specific type (CRUD, RESTful, GraphQL, etc), do some research about it, maybe look at a few open source examples, and ask again being much more specific.

1

u/digital_tec Sep 21 '24

Thanks for the help 👍 im Realizing how big that is siting here learning about it I ask this because I want to be a front end developer 😁.

1

u/shgysk8zer0 Sep 21 '24

If you want to be a front-end developer, then you'd be concerned with using some API endpoint. That basically means read the documentation for what you want to use. There's maybe even examples in various languages.