7 releases

0.0.7 Aug 29, 2024
0.0.6 Mar 14, 2024
0.0.4 Jul 7, 2023
0.0.2 Apr 26, 2023

#1689 in Web programming

Download history 7/week @ 2024-07-24 126/week @ 2024-08-28 3/week @ 2024-09-04 11/week @ 2024-09-11 13/week @ 2024-09-18 18/week @ 2024-09-25 8/week @ 2024-10-02

330 downloads per month

MIT license

18KB
324 lines

Introduction

This crate provides a simple interface for fetching oEmbed data from known providers based on the oembed specification.

Usage

use oembed_rs::{find_provider, fetch, ConsumerRequest};

async fn example() {
    let url = "https://twitter.com/user/status/1000000000000000000";
    let (_, endpoint) = find_provider(url).expect("unknown provider");

    let response = fetch(
       &endpoint.url,
       ConsumerRequest {
           url,
           max_width: Some(1000),
           max_height: Some(500),
           ..ConsumerRequest::default()
       },
    )
    .await
    .expect("failed to fetch oembed data");
}

Roadmap

  • Add support for custom providers
  • Return known errors from the specification properly
  • Support the discovery flow

lib.rs:

Documentation

This crate provides a simple interface for fetching oEmbed data from known providers.

Example

use oembed_rs::{find_provider, fetch, ConsumerRequest};

async fn example() {
    let url = "https://twitter.com/user/status/1000000000000000000";
    let (_, endpoint) = find_provider(url).expect("unknown provider");

    let response = fetch(
       &endpoint.url,
       ConsumerRequest {
           url,
           max_width: Some(1000),
           max_height: Some(500),
           ..ConsumerRequest::default()
       },
    )
    .await
    .expect("failed to fetch oembed data");
}

Dependencies

~4–20MB
~226K SLoC