{"id":13726179,"url":"https://github.com/hcarty/ezrest","last_synced_at":"2025-04-09T17:33:21.015Z","repository":{"id":55563196,"uuid":"234655724","full_name":"hcarty/ezrest","owner":"hcarty","description":"Easy REST requests using cohttp","archived":false,"fork":false,"pushed_at":"2021-05-19T04:57:20.000Z","size":16,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T19:39:13.844Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hcarty.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-17T23:45:49.000Z","updated_at":"2024-11-05T00:19:55.000Z","dependencies_parsed_at":"2022-08-15T03:11:13.482Z","dependency_job_id":null,"html_url":"https://github.com/hcarty/ezrest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcarty%2Fezrest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcarty%2Fezrest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcarty%2Fezrest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcarty%2Fezrest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hcarty","download_url":"https://codeload.github.com/hcarty/ezrest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248077643,"owners_count":21044001,"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-08-03T01:02:54.944Z","updated_at":"2025-04-09T17:33:20.791Z","avatar_url":"https://github.com/hcarty.png","language":"OCaml","funding_links":[],"categories":["OCaml"],"sub_categories":[],"readme":"# Easy REST requests using cohttp\n\nSee `ezrest.mli` for detailed usage information.\n\n## Example usage\nLet's take a look at what it's like to use Ezrest from a REPL.\n```ocaml require-package=ezrest env=demo\n# #require \"ezrest\"\n```\n\nFirst, a simple `HEAD` request.\n```ocaml env=demo\n# let site = Uri.of_string \"http://jsonplaceholder.typicode.com/\"\nval site : Uri.t = \u003cabstr\u003e\n# Ezrest.head site\n- : Cohttp.Response.t Ezrest.result =\nOk\n {Cohttp.Response.encoding = Cohttp__.Transfer.Unknown; headers = \u003cabstr\u003e;\n  version = `HTTP_1_1; status = `OK; flush = false}\n```\n\nNow we can `GET` some content, failing if the site tries to redirect us.\n```ocaml env=demo\n# Ezrest.get ~follow:0 site\n- : string Ezrest.result =\nOk\n \"\\n\u003c!DOCTYPE html\u003e\\n\u003chtml lang=\\\"en\\\"\u003e\\n\u003chead\u003e\\n\u003cmeta charset=\\\"utf-8\\\" /\u003e\\n\u003cmeta name=\\\"viewport\\\" content=\\\"width=device-width, initial-scale=1, shrink-to-fit=no\\\" /\u003e\\n\u003clink rel=\\\"stylesheet\\\" href=\\\"/style.css\\\" /\u003e\\n\u003clink rel=\\\"stylesheet\\\" href=\\\"https://cdnjs.cloudflare.com/ajax/libs/prism/1.21.0/themes/prism-tom\"... (* string length 6949; truncated *)\n```\n\nWe can `PUT` and `POST` too!\n```ocaml env=demo\n# let put_site = Uri.with_path site \"/posts/1\"\nval put_site : Uri.t = \u003cabstr\u003e\n# Ezrest.put put_site\n- : string Ezrest.result = Ok \"{\\n  \\\"id\\\": 1\\n}\"\n# let post_site = Uri.with_path site \"/posts\"\nval post_site : Uri.t = \u003cabstr\u003e\n# Ezrest.post post_site\n- : string Ezrest.result = Ok \"{\\n  \\\"id\\\": 101\\n}\"\n```\n\nAnd `DELETE` if that's what's necessary.\n```ocaml env=demo\n# Ezrest.delete put_site\n- : string Ezrest.result = Ok \"{}\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhcarty%2Fezrest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhcarty%2Fezrest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhcarty%2Fezrest/lists"}