DEV Community

Maximo Martinez Soria
Maximo Martinez Soria

Posted on • Edited on

2 2

HTTP Explained

HTTP stands for Hyper Text Transfer Protocol and is the one that specifies the rules on the communication between two computers through internet.

Verbs

The verbs are actions that define what each request is about to do.

  • GET: fetch data.
  • HEAD: get headers. It's like a GET request but without content.
  • POST: create information.
  • PUT / PATCH: update information.
  • DELETE: delete information.

Verbs, allow us to have different responses for only one endpoint.

We could create lots of endpoints for a resource or we can just use the main word and use the verbs.

For example:

  • GET /books
  • POST /books
  • DELETE /books

Is better than:

  • GET /get-all-books
  • POST /create-a-book
  • DELETE /delete-book

Status

Every request is going to return a status code. Let's see which codes exist and why.

  • 1xx: pending. Nothing happened yet.
  • 2xx: success.
  • 3xx: usually a redirect.
  • 4xx: client-side errors.
  • 5xx: server-side errors.

Common Status Codes

  • 200: everything is ok. Usually used in GET request.
  • 201: everything is ok. Usually used in POST / PUT request.
  • 204: usually used to say that a DELETE request was completed successfully. The resource was deleted.
  • 400: bad request. Something is wrong in the request.
  • 401: unauthorised. You need to specify credentials first.
  • 403: forbidden. You don't have permissions over that resource even though you are authenticated.
  • 404: not found. Resource doesn't exist.
  • 500: internal server error. The request couldn't be processed.

API Trace View

How I Cut 22.3 Seconds Off an API Call with Sentry

Struggling with slow API calls? Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay