Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
examples
lib
.gitignore
.travis-ci.sh
.travis.yml
Makefile
README.md

README.md

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