{"id":20191442,"url":"https://github.com/leviroth/ocaml-reddit-api","last_synced_at":"2025-04-10T09:38:25.411Z","repository":{"id":37987760,"uuid":"288857371","full_name":"leviroth/ocaml-reddit-api","owner":"leviroth","description":"An OCaml wrapper to Reddit's API","archived":false,"fork":false,"pushed_at":"2025-03-08T14:48:20.000Z","size":4071,"stargazers_count":13,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T08:38:48.659Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leviroth.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-19T23:16:27.000Z","updated_at":"2023-05-03T18:03:38.000Z","dependencies_parsed_at":"2024-12-17T13:33:12.345Z","dependency_job_id":"b364e313-d405-4506-a9d6-a0bd086215ee","html_url":"https://github.com/leviroth/ocaml-reddit-api","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leviroth%2Focaml-reddit-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leviroth%2Focaml-reddit-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leviroth%2Focaml-reddit-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leviroth%2Focaml-reddit-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leviroth","download_url":"https://codeload.github.com/leviroth/ocaml-reddit-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248192805,"owners_count":21062746,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T03:49:09.169Z","updated_at":"2025-04-10T09:38:25.391Z","avatar_url":"https://github.com/leviroth.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"`reddit_api` is a set OCaml client libraries for Reddit's API.\n\n`reddit_api_kernel` provides:\n\n* Types for representing Reddit's API parameters and responses\n* Functions for building HTTP requests and handling the associated responses\n  for Reddit's API endpoints.\n\n`reddit_api_async` provides a client for sending these requests to Reddit and\nsome utilities for common usage patterns. It handles authentication and\nReddit's rate-limiting headers.\n\n# Documentation\n\n[Here](https://leviroth.github.io/ocaml-reddit-api/). I recommend the\n[`Reddit_api_kernel.Endpoint`](https://leviroth.github.io/ocaml-reddit-api/reddit_api_kernel/Reddit_api_kernel/Endpoint/index.html)\nand\n[`Reddit_api_async.Connection`](https://leviroth.github.io/ocaml-reddit-api/reddit_api_async/Reddit_api_async/Connection/index.html)\nmodules as entry points.\n\n# Example\n\n```ocaml\nlet print_links credentials =\n  let connection = Connection.create credentials ~user_agent:\"Link printer\" in\n  let subreddit =\n    Subreddit_name.combine (List.map ~f:Subreddit_name.of_string [ \"ocaml\"; \"redditdev\" ])\n  in\n  let%bind link_listing =\n    Connection.call_exn connection (Endpoint.top ~since:Year ~subreddit ())\n  in\n  let links = Listing.children link_listing in\n  List.iter links ~f:(fun link -\u003e\n      print_s\n        [%sexp\n          { title : string = Thing.Link.title link\n          ; url : string option = Option.map (Thing.Link.url link) ~f:Uri.to_string\n          ; author : Username.t option = Thing.Link.author link\n          ; score : int = Thing.Link.score link\n          }]);\n  return ()\n```\n\n# Goals and non-goals\n\n## Goals\n\n- Provide a typed interface to Reddit's API endpoints and responses.\n- Encode knowledge, documented or otherwise, about correct usage of the API via\n  the type system.\n  - Don't raise exceptions if Reddit is behaving \"as expected.\"\n  - Express corner cases in response types. For example, are there surprising\n    cases where a field might not be present? Make the field optional instead\n    of making each user discover this on their own.\n  - Handle common Reddit server issues such as 503 errors automatically, or\n    else warn about them via the response type.\n- Provide workarounds when we get the above wrong:\n  - The ability to directly edit the HTTP requests generated for each endpoint.\n  - A `Connection.call_raw` function that allows users to access HTTP responses\n    directly.\n\n## Non-goals\n\n- Be perfect\n  - Reddit's API is not very well documented.  Determining which inputs and\n    outputs are legal is largely a matter of trial and error. At any given\n    time, it's likely that we allow some invalid combination of inputs, or\n    forbid a valid combination, or fail to handle some valid response.\n- Express \"unexpected\" Reddit behavior in the type system.\n  - If we get something from Reddit that we don't understand, we'll just raise.\n    We don't make every function return a ``(_, [`couldn't_parse_response])\n    Result.t)``.\n\n# Credits\n\nThanks to [PRAW](https://github.com/praw-dev/praw/) for providing innumerable\nexamples of Reddit API client code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleviroth%2Focaml-reddit-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleviroth%2Focaml-reddit-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleviroth%2Focaml-reddit-api/lists"}