{"id":18841914,"url":"https://github.com/diskuv/dkstdrestapis","last_synced_at":"2025-07-14T16:05:56.162Z","repository":{"id":245030026,"uuid":"815393134","full_name":"diskuv/DkStdRestApis","owner":"diskuv","description":"The standard REST API clients and mock servers for https://github.com/diskuv/dkcoder","archived":false,"fork":false,"pushed_at":"2024-12-07T05:10:37.000Z","size":22583,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-14T07:45:51.393Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":false,"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/diskuv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-Apache2","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,"zenodo":null}},"created_at":"2024-06-15T03:23:15.000Z","updated_at":"2024-12-07T05:10:44.000Z","dependencies_parsed_at":"2024-11-08T02:53:18.405Z","dependency_job_id":"0572dd53-338e-4c9d-ba39-736c0623834b","html_url":"https://github.com/diskuv/DkStdRestApis","commit_stats":null,"previous_names":["diskuv/dkstdrestapis"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/diskuv/DkStdRestApis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diskuv%2FDkStdRestApis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diskuv%2FDkStdRestApis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diskuv%2FDkStdRestApis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diskuv%2FDkStdRestApis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diskuv","download_url":"https://codeload.github.com/diskuv/DkStdRestApis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diskuv%2FDkStdRestApis/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265314335,"owners_count":23745247,"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-08T02:53:02.170Z","updated_at":"2025-07-14T16:05:56.151Z","avatar_url":"https://github.com/diskuv.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DkCoder REST APIs\n\n`DkStdRestApis` is a monorepo project containing generated REST client code for multiple REST services.\nThe intent is to be a one-stop shop for the common REST services for OCaml users, especially anyone using [DkCoder](https://github.com/diskuv/dkcoder#readme).\n\n\u003e If you would like to support this project, please consider adding a star to the [DkCoder GitHub project](https://github.com/diskuv/dkcoder). *That is also the place to leave issues and feedback!*\n\n## Documents\n\n| Title     | Link                                                                           |\n| --------- | ------------------------------------------------------------------------------ |\n| NotStripe | [src/DkStdRestApis_NotStripe/README.md](src/DkStdRestApis_NotStripe/README.md) |\n\n## Licenses\n\nThe generated clients in `src/` are liberally licensed with the [LICENSE-Apache2](./LICENSE-Apache2) Apache 2.0 license.\n\nThe `dk` and `dk.cmd` build tools are [LICENSE-OSL3](./LICENSE-OSL3) OSL 3.0 licensed with prompts for additional licenses for the OCaml-modified LGPL license and DkSDK license.\n\n## Quick Start\n\n\u003e Prerequisites: opam 2.2.0+. On Unix that is `bash -c \"sh \u003c(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) --version 2.2.0~beta3\"` and on Windows that is `winget install opam`\n\nCheckout the project:\n\n```shell\ngit clone https://github.com/diskuv/DkStdRestApis.git\ncd DkStdRestApis\n```\n\nand create an exploratory opam switch:\n\n```sh\n# DkStdRestApis requires OCaml 5.2.0+ until OCaml 4.12.3\n# (https://github.com/ocaml/ocaml/pull/13204) is released. DkStdRestApis will be\n# published to opam once APIs + dependencies stabilize.\nopam switch create . 5.2.0 --no-install\n\n# Small set of transitive dependencies; 5 of 21 are build-time dependencies.\n#  ocamlbuild, dune, ocamlfind, stringext, routes, ocaml-syntax-shims, csexp,\n#  topkg, dune-configurator, ptime, fmt, bigstringaf, cstruct, angstrom, hex,\n#  uri, json-data-encoding, jsonm, sexplib0, uutf, ezjsonm,.\nopam install --subpath src/ . --yes --deps-only\n\n# We'll add some backends and dev tools.\n#  1. DkStdRestApis has scaffolding for REST servers. Bring your own\n#  web server backend. Includes an example for [tiny_httpd] (+3 dependencies).\n#  2. REST clients are generated. Bring your own web agent backend. Includes an\n#  example for an unreleased [cohttp-curl-lwt] (+9 deps).\nopam pin add cohttp-curl git+https://github.com/mirage/ocaml-cohttp.git#77fb272f8eac61b9d94067450c75b58fe4c2e122 --yes\nopam pin add tiny_httpd git+https://github.com/c-cube/tiny_httpd.git#9eb3cbfc70d112d09eccada835667b76d1f758f6 --yes\nopam install cohttp-curl-lwt utop ocaml-lsp-server odoc --yes\n```\n\nand then start exploring the [Stripe REST API](https://docs.stripe.com/api)\nfrom its [OpenAPI 3.0.0 specification](https://github.com/stripe/openapi#readme):\n\n```ocaml\n$ opam exec dune utop\n\n#require \"DkStdRestApis_NotStripe\" ;;\n#require \"DkStdRestApis_NotStripe.Clients\" ;;\nopen DkStdRestApis_NotStripe ;;\nopen DkStdRestApis_NotStripe_C ;;\n\n(* Do you have a Stripe account? Then:\n   1. Replace the [bearer].\n   2. Add ~cacerts=\"/etc/ssl/certs/ca-certificates.crt\" on Linux; aka. ca-build.crt.\n\n   Otherwise skip to the \"Print Curl\" section! *)\nmodule Agent = (val Curl2.create_cohttp_curl_lwt_agent ~server_url:\"https://api.stripe.com\" ~bearer:\"YOUR_STRIPE_API_TEST_SECRET_KEY\" ~headers:[(\"stripe-version\", \"2024-04-10\")] ()) ;;\nmodule StripeClient = Stripe.Client (Agent) ;;\n\nStripeClient.getCustomers ~limit:1 None ;;\n\n(* Print Curl: Print 'curl ...' commands rather than trying to execute the web request. *)\n\nmodule Agent = (val CurlCmd.create_agent ~server_url:\"https://api.stripe.com\" ~bearer:\"YOUR_STRIPE_API_TEST_SECRET_KEY\" ~headers:[(\"stripe-version\", \"2024-04-10\")] ()) ;;\nmodule StripeClient = Stripe.Client (Agent) ;;\n\nCurlCmd.print @@ StripeClient.getCustomers ~limit:1 None ;;\n\n#quit ;;\n```\n\nOkay, we have a way to print Curl commands.\n\nLet's start the server in [ServerTiny.ml](src/DkStdRestApis_NotStripe/ServerTiny.ml):\n\n```sh\n$ opam exec -- dune exec src/DkStdRestApis_NotStripe/ServerTiny.exe\nlistening on http://127.0.0.1:8080\n```\n\nand run a couple Curl commands in **another terminal**:\n\n```sh\n$ curl -H \"Content-Type: application/x-www-form-urlencoded\" http://127.0.0.1:8080/v1/customers/123\n{\"error\":{\"message\":\"Customer 123 not found.\",\"type\":\"api_error\"}}\n\n$ curl -d \"email=elves@northpole.ca\" -d \"name=Santa Claus\" http://127.0.0.1:8080/v1/customers/123\n{\"created\":1719209196,\"email\":\"elves@northpole.ca\",\"id\":\"123\",\"livemode\":false,\"name\":\"Santa Claus\",\"object\":\"customer\"}\n\n$ curl -H \"Content-Type: application/x-www-form-urlencoded\" http://127.0.0.1:8080/v1/customers/123\n{\"created\":1719209196,\"email\":\"elves@northpole.ca\",\"id\":\"123\",\"livemode\":false,\"name\":\"Santa Claus\",\"object\":\"customer\"}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiskuv%2Fdkstdrestapis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiskuv%2Fdkstdrestapis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiskuv%2Fdkstdrestapis/lists"}