8 releases

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

#1594 in Web programming

Download history 79/week @ 2024-08-23 48/week @ 2024-08-30 2/week @ 2024-09-06 14/week @ 2024-09-13 14/week @ 2024-09-20 19/week @ 2024-09-27 3/week @ 2024-10-04 1/week @ 2024-11-15 139/week @ 2024-11-22 7/week @ 2024-11-29

147 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–16MB
~200K SLoC