OpenGraph Fetch

by ayaka.io

API

Method: GET

Path: /

Query Params:

Response:

TypeScript definition
interface OpenGraph {
  title: string
  type: string
  image: string
  url: string
  audio: string
  description: string
  determiner: string
  locale: string
  localeAlternate: string[]
}

interface Response {
  title: string
  description: string
  icon: string
  author: string
  keywords: string[]
  openGraph: OpenGraph
}
          

Golang struct definition
type OpenGraph struct {
	Title string `json:"title"`
	Type string `json:"type"`
	Image string `json:"image"`
	URL string `json:"url"`
	Audio string `json:"audio"`
	Description string `json:"description"`
	Determiner string `json:"determiner"`
	Locale string `json:"locale"`
	LocaleAlternate []string `json:"localeAlternate"`
}

type Response struct {
	Title string `json:"title"`
	Description string `json:"description"`
	Icon string `json:"icon"`
	Author string `json:"author"`
	Keywords []string `json:"keywords"`
	OpenGraph OpenGraph `json:"openGraph"`
}

Usage

Send a GET request to https://og.ayaka.io/?url=https://example.com to get the OpenGraph data of the URL.

cURL Example

curl 'https://og.ayaka.io/?url=https://example.com'

fetch Example

const res = await fetch('https://og.ayaka.io/?url=https://example.com')
const data = await res.json()
console.log(data)