this post was submitted on 18 Jun 2025
5 points (85.7% liked)

Programming

13932 readers
1 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 2 years ago
MODERATORS
 

Consider I only know apis are structured data that can be called or modified from within a program, and have no real further knowledge in real use cases nor in networking.

Where should I start from? Should I study backend?

I prefer docs rather than videos.

you are viewing a single comment's thread
view the rest of the comments
[–] nickwitha_k@lemmy.sdf.org 1 points 2 weeks ago (2 children)

What programming language do you have already or intend to learn?

[–] dontblink@feddit.it 1 points 2 weeks ago (1 children)

I know some basic Rust (currently at chapter 9) and a little bit of JavaScript.

I'm trying to work with headless CMSs and that requires some understanding on how APIs work..

Even tho I wouldn't want to stick with JS, I don't really want to dig into frameworks and dependency hells.

But I like the concept and I need to build a site that grabs some data from an external api, so a headless cms would be my choice to grab the data and structure them there in order to be rendered later in something like a static site generator (I'm quite good at Hugo). Or will learn some basic React and try to build a template on my own there...

[–] nickwitha_k@lemmy.sdf.org 1 points 2 weeks ago

In that case, my suggestion would be to target implementing a REST API with OpenAPI (formerly Swagger). There are server code generators for both Rust and JS (multiple flavors, I think).

Basically, the workflow is something like this:

  1. Create your API spec skeleton (YAML or JSON, pick your poison). This will have all of the required sections like info
  2. Pick your first endpoint and define it in the paths section. Probably start with during simple like a GET. This will mean that you mainly have to worry about defining your responses (at minimum HTTP2XX and HTTP4XX, preferably with a catchall error response for HTTP5XX responses) and their schemas.
  3. Run the code generator. This should generate files with stubbed-out definitions for interfaces (or the equivalent for your language of choice) for your response methods. Generally, you do NOT want to add any code to these files as they will be overwritten anytime you update your API spec.
  4. Implement the methods to handle the stubbed out interfaces. Ex. A hello-world interface would likely need to be implemented with a method or function that returns the string "hello world".

The reason that I recommend OpenAPI in writing REST APIs is that it helps to layout the API contracts before you even start coding. This helps with keeping typing consistent, give you a clear milestone for implement, and makes creating clients really easy.

Extra benefit is that OpenAPI is (mostly) language agnostic, so, as long as you have a codegen or some good boilerplate, you can use it for any language, which can give you a safe place to start when learning a new language.