The Furniture Bros API docs
  • Start here
    • Introduction
    • Get Started
    • Authentication
    • Making a request
    • Examples
    • Functionalities
    • Release Notes
      • 5 Dec 2024
      • 4 Dec 2023
      • 30 Nov 2023
      • 24 Nov 2023
      • 20 Nov 2023
      • 14 Nov 2023
      • 26 Oct 2023
      • 23 Oct 2023
      • 05 Oct 2023
    • Glossary
      • API terms
      • Functionality terms
  • API Endpoints
    • Account
    • Product
    • Cart
    • Address
    • Orders
    • Statistics
Powered by GitBook
On this page
  • cURL
  • JavaScript
  • Python
  • Java
  1. Start here

Examples

This page shows you the code-snippet for the various languages.

This section provides an example of an API request in different programming languages to help you quickly integrate The Furniture Bros API into your application. In the API docs section, each endpoint includes code snippets in various languages for easy copy-pasting. For this example, we will be using this endpoint:

POST /auth/register - This endpoint allows you to create and register an account.

cURL

curl --location 'http://thefurniturebros.com/auth/register' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "John Dane",
    "email":"jon_dane@gmail.com",
    "password":"123456",
    "admin": false
}'

JavaScript

const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

const raw = JSON.stringify({
  "name": "John Dane",
  "email": "jon_dane@gmail.com",
  "password": "123456",
  "admin": false
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("http://thefurniturebros.com/auth/register", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

Python

import http.client
import json

conn = http.client.HTTPConnection("thefurniturebros.com")
payload = json.dumps({
  "name": "John Dane",
  "email": "jon_dane@gmail.com",
  "password": "123456",
  "admin": False
})
headers = {
  'Content-Type': 'application/json'
}
conn.request("POST", "/auth/register", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Java

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"name\": \"John Dane\",\r\n    \"email\":\"jon_dane@gmail.com\",\r\n    \"password\":\"123456\",\r\n    \"admin\": false\r\n}");
Request request = new Request.Builder()
  .url("http://thefurniturebros.com/auth/register")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
PreviousMaking a requestNextFunctionalities

Last updated 6 months ago