package reddit_api_async
Install
Dune Dependency
Authors
Maintainers
Sources
md5=47a9d626691bca0b95e25b5e563bbffd
sha512=31bd453ff554519816f80e181299a2dcaed631b1c8ee07ee2d0a10682e444414aedca5ed42d377924e8ce98689499d1cafc228282d7863daba92bfb1e38808c5
Description
Published: 18 Dec 2020
README
README.md
Reddit_api
is a set OCaml client libraries for Reddit's API.
reddit_api_kernel
provides:
Types for representing Reddit's API parameters and responses
Functions for building HTTP requests and handling the associated responses for Reddit's API endpoints.
reddit_api_async
provides a client for sending these requests to Reddit and some utilities for common usage patterns. It handles authentication and Reddit's rate-limiting headers.
Documentation
Here. I recommend the Reddit_api_kernel.Api
and Reddit_api_async.Connection
modules as entry points.
Design philosophy and caveats
Reddit_api
aims to help users navigate the Reddit API via OCaml types. For example, many HTTP endpoints have parameters that cannot be used in conjunction with each other. In such cases, we wrap these parameters in variant types so that users don't have to discover the conflict for themselves. For another example, we try to wrap outputs in types that express the full range of possible responses from Reddit. If Reddit_api
ever raises, we regard this as a bug and prefer to express this possibility via a type rather than forcing users to anticipate exceptions. Conversely, if some Response type t
always has a value of type v
, we try to provide a function t -> v
rather than providing t -> v option
and forcing users to guess when the result might be None
.
The caveat is that this is hard. Reddit's API is not very well documented. Determining which inputs and outputs are legal is largely a matter of trial and error. At any given time, it's likely that we allow some invalid combination of inputs, or forbid a valid combination, or fail to handle some valid response.
If this caveat bites you, reports and pull requests are certainly welcome. To facilitate workarounds, we also provide:
A
?param_list_override:((string * string list) list -> (string * string list) list)
option on each API endpoint that allows the HTTP parameters to be manipulated directly.A
Connection.call_raw
function that allows users to access HTTP responses directly.
Credits
Thanks to PRAW for providing innumerable examples of Reddit API client code.
Dependencies (8)
-
sequencer_table
>= "v0.14.0" & < "v0.15"
-
reddit_api_kernel
= version
-
ezjsonm
>= "1.0"
-
core
>= "v0.14.0" & < "v0.15"
-
cohttp-async
>= "2.5.4" & < "5.0.0"
-
async_ssl
>= "v0.14.0" & < "v0.15"
-
async
>= "v0.14.0" & < "v0.15"
-
dune
>= "2.5"
Dev Dependencies (1)
-
odoc
with-doc
Used by
None
Conflicts
None