mwhittaker / duckduckgo-ocaml

DuckDuckGo OCaml API

Home Page:http://mwhittaker.github.io/duckduckgo-ocaml/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DuckDuckGo Build Status

This repository contains Async integrated OCaml bindings for the DuckDuckGo API.

Getting Started

The DuckDuckGo module exports three functions you can use to issue DuckDuckGo queries.

  1. query which returns a string
  2. query_json which returns a Yojson.Basic.json
  3. query_record which returns a DuckDuckGo.response

We can use query_record to query DuckDuckGo about OCaml. Here's query_record's simplified type:

string -> (DuckDuckGo.response, exn) Core.Std.Result.t Async.Std.Deferred.t

query_record takes in a query string and returns a deferred DuckDuckGo.response result. We can use Async's try_with to unwrap the result and print the response of the query.

DuckDuckGo.query_record "ocaml" >>| function
| Ok response -> print_endline response.abstract
| Error _     -> print_endline "no abstract found"

For more complete examples, please refer to the examples directory.

Documentation

Documentation can be found online at http://mwhittaker.github.io/duckduckgo-ocaml/. Alternatively, you can build the documentation yourself:

make doc && firefox doc.docdir/index.html

Dependencies

You can install these dependencies using opam:

opam install core async atdgen cohttp textwrap uri yojson

Resources

About

DuckDuckGo OCaml API

http://mwhittaker.github.io/duckduckgo-ocaml/


Languages

Language:OCaml 90.5%Language:CSS 5.2%Language:Makefile 2.4%Language:Shell 1.8%