Forge API

Core Concepts

Calling Endpoints

Every Forge API endpoint is a standard HTTPS REST endpoint. If your application can call a REST API, it can call Forge API without any special SDK or library.

Nothing proprietary

Forge API uses ordinary HTTPS URLs. Your frontend, backend, mobile app, Postman or automated tests can all call the same endpoint.

Endpoint URL

Throughout this guide we'll use the following endpoint:

URL
https://apis.getforgeapi.com/abc12/products

Browser

GET endpoints can simply be pasted into your browser.

URL
https://apis.getforgeapi.com/abc12/products

JavaScript Fetch

fetch.jsJavaScript
const response = await fetch("https://apis.getforgeapi.com/abc12/products");

const products = await response.json();

console.log(products);

TypeScript

products.tsTypeScript
type Product = {
  id: number;
  name: string;
  price: number;
};

const response = await fetch("https://apis.getforgeapi.com/abc12/products");

const products: Product[] =
  await response.json();

console.log(products);

Axios

axios.tsTypeScript
import axios from "axios";

const { data } = await axios.get("https://apis.getforgeapi.com/abc12/products");

console.log(data);

cURL

bash
curl https://apis.getforgeapi.com/abc12/products

Protected Endpoints

If your project or endpoint requires secret request headers, simply include them with the request.

bash
curl \
  -H "x-api-key: your-secret-value" \
  https://apis.getforgeapi.com/abc12/products
JavaScript
await fetch("https://apis.getforgeapi.com/abc12/products", {
  headers: {
    "x-api-key": "your-secret-value",
  },
});

Protect your secrets

Never expose secret header values inside public frontend applications. Keep them on trusted servers or secure internal tools whenever possible.

React Example

Products.tsxTSX
useEffect(() => {
  async function loadProducts() {
    const response = await fetch("https://apis.getforgeapi.com/abc12/products");

    const products = await response.json();

    console.log(products);
  }

  loadProducts();
}, []);

Error Handling

fetch.tsTypeScript
const response = await fetch("https://apis.getforgeapi.com/abc12/products");

if (!response.ok) {
  throw new Error(
    `Request failed: ${response.status}`
  );
}

const data = await response.json();

Tip

During frontend development it's useful to create endpoints returning 400, 401, 404 and 500 responses so you can test every error state in your application.

Start testing your frontend

Call your Forge API endpoints exactly like a production REST API.