GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - aws-samples/sample-serverless-oembed

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
__tests__
__tests__
 
 
events
events
 
 
examples
examples
 
 
images
images
 
 
src
src
 
 
.gitignore
.gitignore
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
DEPLOYMENT.md
DEPLOYMENT.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
THIRD_PARTY_LICENSES
THIRD_PARTY_LICENSES
 
 
build.config.mjs
build.config.mjs
 
 
buildspec.yml
buildspec.yml
 
 
deploy.sh
deploy.sh
 
 
dev.parameters.example
dev.parameters.example
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
samconfig.toml
samconfig.toml
 
 
template.yaml
template.yaml
 
 
test-env.json
test-env.json
 
 

Repository files navigation

Serverless oEmbed Provider

License: MIT Node.js

A serverless oEmbed provider boilerplate that enables rich content previews when your content is shared on social media platforms, messaging apps, and other services that support oEmbed.

What is oEmbed?

oEmbed is the standard used to show rich previews when sharing links. When you share a link on platforms like Slack, Discord, Twitter, or Facebook, they use oEmbed to fetch and display rich content previews.

Example of an oEmbed preview card on Slack for a CNN link:

OEmbed example

Features

  • ✅ Complete oEmbed 1.0 specification compliance
  • ✅ Custom domain support with SSL certificates
  • ✅ Production monitoring with CloudWatch dashboards
  • ✅ Security best practices and input validation
  • ✅ Cost-optimized serverless architecture
  • ✅ Multi-environment support (dev/staging/prod)

Quick Start

Deploy with SAM CLI (Recommended)

# Clone and setup
git clone https://github.com/aws-samples/serverless-oembed.git
cd serverless-oembed
npm install

# Configure parameters
cp dev.parameters.example dev.parameters
# Edit dev.parameters with your values

# Deploy using helper script (handles parameter formatting automatically)
./deploy.sh dev --guided

See DEPLOYMENT.md for detailed instructions.

Supported Content Types

  • Video: Interactive players with iframe embeds and thumbnails
  • Photo: High-resolution images with responsive sizing
  • Rich: Interactive widgets and custom HTML content
  • Link: Simple metadata previews for link sharing

oEmbed Discoverability

To enable automatic discovery by social platforms and other services, add oEmbed discovery links to your content pages:

HTML Discovery Tags

Add these <link> tags to the <head> section of your content pages:

<!-- JSON oEmbed discovery -->
<link
  rel="alternate"
  type="application/json+oembed"
  href="https://your-oembed-endpoint.com/oembed?url=https%3A%2F%2Fyoursite.com%2Fvideo%2F123"
  title="Video Title"
/>

<!-- XML oEmbed discovery (optional) -->
<link
  rel="alternate"
  type="text/xml+oembed"
  href="https://your-oembed-endpoint.com/oembed?url=https%3A%2F%2Fyoursite.com%2Fvideo%2F123"
  title="Video Title"
/>

Note: The href URL must be properly URL-encoded. The format parameter is only needed if your endpoint requires it explicitly.

oEmbed Specification Compliance

This provider is 100% compliant with the official oEmbed 1.0 specification:

✅ Request Parameters: Supports all official parameters (url, maxwidth, maxheight, format)
✅ Response Formats: JSON (default) and XML with proper Content-Type headers
✅ Content Types: All four types (photo, video, rich, link) with required fields
✅ HTTP Status Codes: Official error codes (404, 501, 401) as per spec
✅ Discovery Methods: Both HTML <link> tags and HTTP Link headers
✅ Security: URL scheme filtering, XSS prevention, proper XML escaping

Platform Integration

Popular platforms that support oEmbed discovery:

  • Discord: Automatically detects and displays rich previews
  • Slack: Shows interactive content previews in messages
  • Twitter/X: Displays rich media cards
  • Facebook: Shows enhanced link previews
  • LinkedIn: Displays professional content previews
  • Reddit: Shows embedded content in posts

Backend Integration

Customize src/integration/getContentMetadata.mjs to connect to your backend:

export async function getContentMetadata(url, params = {}) {
  const contentId = extractContentId(url);
  const content = await fetchContentFromBackend(contentId);

  return {
    type: "video", // or "photo", "rich", "link"
    title: content.title,
    author_name: content.author,
    html: generateEmbedHtml(content),
    width: content.width,
    height: content.height,
  };
}

See Integration Guide for detailed instructions.

API Usage

Your oEmbed endpoint will be available at:

https://your-endpoint/oembed?url=https://yourcompany.com/content/123

Example response:

{
  "version": "1.0",
  "type": "video",
  "title": "Sample Video",
  "provider_name": "Your Company",
  "html": "<iframe src='...' width='800' height='450'></iframe>",
  "width": 800,
  "height": 450
}

Expected Costs

This serverless architecture is designed to be cost-effective for most use cases:

Basic Deployment (Default Configuration)

  • AWS Lambda: ~$0.20-1.00/month for typical usage (1,000-10,000 requests)
  • API Gateway: ~$0.35-3.50/month (1,000-10,000 requests)
  • CloudWatch Logs: ~$0.50-2.00/month
  • Custom Domain (optional): ~$0.50/month for Route 53 hosted zone
  • Total: ~$1.50-7.00/month for typical small to medium usage

High-Traffic Deployment (With Caching Enabled)

  • Basic costs: ~$1.50-7.00/month
  • API Gateway Cache (0.5GB): ~$13.50/month
  • Total: ~$15.00-20.50/month for high-traffic scenarios

Cost Optimization Tips

  • Start without caching - Enable only when you exceed 1,000+ requests/day
  • Monitor usage - Use CloudWatch dashboards to track actual costs

Local Development

# Clone and setup
git clone https://github.com/aws-samples/serverless-oembed-provider.git
cd serverless-oembed-provider
npm install

# Test locally
sam build
sam local start-api --env-vars test-env.json
curl "http://localhost:3000/oembed?url=https://yourdomain.com/video/123"

# Run tests
npm test

Support

  • Examples: oEmbed response examples for inspiration
  • Deployment: Deployment Guide for detailed deployment instructions
  • Integration: Integration Guide for backend integration
  • Issues: GitHub Issues for support

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Readme
License

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

3 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

Generated from amazon-archives/__template_MIT-0
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.