Skip to main content
API Documentation

SDKs

OG Fetch is intentionally SDK-free: the API is a thin REST surface, and we want you to be able to copy a single curl snippet into your stack without adopting a new dependency. Here's how to call it idiomatically in the languages we get asked about most.

JavaScript / TypeScript

Use the built-in fetch — no dependency needed. Add a tiny wrapper to centralize the API key and error handling:

const OG_FETCH_KEY = process.env.OG_FETCH_KEY!;
export async function ogfetch<T>(path: string, init: RequestInit = {}): Promise<T> {
const response = await fetch(`https://api.ogfetch.com${path}`, {
...init,
headers: { Authorization: `Bearer ${OG_FETCH_KEY}`, ...(init.headers ?? {}) },
});
if (!response.ok) {
const body = await response.json().catch(() => ({}));
throw new Error(body.message ?? `OG Fetch ${response.status}`);
}
return response.json() as Promise<T>;
}

Python

import os, requests
OG_FETCH_KEY = os.environ["OG_FETCH_KEY"]
def ogfetch(path: str, **kwargs) -> dict:
response = requests.get(
f"https://api.ogfetch.com{path}",
headers={"Authorization": f"Bearer {OG_FETCH_KEY}"},
**kwargs,
)
response.raise_for_status()
return response.json()

Go

package ogfetch
import (
"encoding/json"
"fmt"
"net/http"
"os"
)
var key = os.Getenv("OG_FETCH_KEY")
func Get[T any](path string) (T, error) {
var zero T
req, _ := http.NewRequest("GET", "https://api.ogfetch.com"+path, nil)
req.Header.Set("Authorization", "Bearer "+key)
resp, err := http.DefaultClient.Do(req)
if err != nil { return zero, err }
defer resp.Body.Close()
if resp.StatusCode >= 400 {
return zero, fmt.Errorf("ogfetch %d", resp.StatusCode)
}
var out T
return out, json.NewDecoder(resp.Body).Decode(&out)
}

PHP

<?php
function ogfetch(string $path): array {
$key = getenv('OG_FETCH_KEY');
$ch = curl_init('https://api.ogfetch.com' . $path);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer $key"],
]);
$body = curl_exec($ch);
curl_close($ch);
return json_decode($body, true);
}

Ruby

require 'net/http'
require 'json'
def ogfetch(path)
uri = URI("https://api.ogfetch.com#{path}")
req = Net::HTTP::Get.new(uri)
req['Authorization'] = "Bearer #{ENV['OG_FETCH_KEY']}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
JSON.parse(res.body)
end

OpenAPI spec

Want generated types/clients for your language? An OpenAPI spec is on the roadmap. Until then, every endpoint reference page lists request and response shapes — copy from there.