Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mbuczko/clj-embodie
Fetching site-embedded data
https://github.com/mbuczko/clj-embodie
clojure oembed open-graph
Last synced: 15 days ago
JSON representation
Fetching site-embedded data
- Host: GitHub
- URL: https://github.com/mbuczko/clj-embodie
- Owner: mbuczko
- Created: 2019-01-13T13:51:11.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-13T13:57:10.000Z (almost 6 years ago)
- Last Synced: 2024-11-17T20:55:48.830Z (about 1 month ago)
- Topics: clojure, oembed, open-graph
- Language: Clojure
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# oEmbed / open-graph info fetcher
[![Clojars Project](https://img.shields.io/clojars/v/defunkt/embodie.svg)](https://clojars.org/defunkt/embodie)
The goal of this project is to fetch [oEmbed](http://oembed.com/), [open-graph](http://ogp.me/) and basic HTML information stored at given URL.
Entire API comes down to:
``` clojure
(require '[embodie.core :as core]
'[embodie.oembed :as oembed])(core/fetch url)
(core/fetch url providers & opts)(oembed/init-oembed-providers)
(oembed/init-oembed-providers location)(oembed/with-oembed-providers providers)
```_providers_ is by vector of defined providers, `[:oembed :open-graph :html]` by default, and can be adjusted, eg. to limit amount of data gathered or simply to fetch data from one particular provider.
The `opts` map is a way to pass additional options, used currently only by `:html` provider to limit number of returned images (3 by default):
``` edn
{:max-images 3}
```Additionally:
`init-oembed-providers` initializes a map of defined oembed providers and defaults to json stored at http://oembed.com/providers.json if no alternative location was provided.
`with-oembed-providers` is a convenience macro which (re)binds variable with oembed providers initialized before.
## Fetching in action
Typical use of API functions:
``` clojure
;; initialize oembed providers from default list
(def providers (oembed/init-oembed-providers));; fetch info using :oembed, :open-graph and :html providers
(oembed/with-oembed-providers providers
(core/fetch "https://www.instagram.com/p/BoRz3GpAhsg/"));; only :html provider and max 1 image
(core/fetch "https://www.instagram.com/p/BoRz3GpAhsg/" [:html] {:max-images 1})```