{"id":25065472,"url":"https://github.com/podlove/hal","last_synced_at":"2025-08-05T22:08:44.138Z","repository":{"id":57504129,"uuid":"170283544","full_name":"podlove/hal","owner":"podlove","description":"Elixir library to generate JSON HAL responses","archived":false,"fork":false,"pushed_at":"2019-02-13T04:11:31.000Z","size":13,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-30T05:43:01.049Z","etag":null,"topics":["elixir","elixir-lang","elixir-library"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/podlove.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2019-02-12T08:47:39.000Z","updated_at":"2021-07-28T00:19:28.000Z","dependencies_parsed_at":"2022-08-27T23:53:33.980Z","dependency_job_id":null,"html_url":"https://github.com/podlove/hal","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/podlove%2Fhal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/podlove%2Fhal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/podlove%2Fhal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/podlove%2Fhal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/podlove","download_url":"https://codeload.github.com/podlove/hal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248361061,"owners_count":21090808,"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":["elixir","elixir-lang","elixir-library"],"created_at":"2025-02-06T19:27:17.333Z","updated_at":"2025-04-14T18:31:01.936Z","avatar_url":"https://github.com/podlove.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HAL\n\n[![Build Status](https://travis-ci.org/podlove/hal.svg?branch=master)](https://travis-ci.org/podlove/hal)\n\nGenerate JSON in [HAL](http://stateless.co/hal_specification.html) format for REST APIs.\n\n## Installation\n\nThe package can be installed by adding `hal` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:hal, \"~\u003e 1.0.0\"}\n  ]\nend\n```\n\n## Basic Usage\n\nBuild a `HAL.Document`:\n\n```elixir\nalias HAL.{Document, Link, Embed}\n\ndocument = \n  %Document{}\n  |\u003e Document.add_link(%Link{rel: \"self\", href: \"/foo\"})\n  |\u003e Document.add_property(:foo, 42)\n  |\u003e Document.add_property(:bar, \"baz\")\n  |\u003e Document.add_embed(%Embed{resource: \"rad:podcast\", embed: %HAL.Document{properties: %{id: 18}}})\n```\n\nThen use `Jason` to encode it to JSON:\n\n```elixir\nJason.encode!(document)\n```\n\n```json\n{\n  \"bar\": \"baz\",\n  \"foo\": 42,\n  \"_embedded\": {\n      \"rad:podcast\": {\n        \"id\": 18\n    }\n  },\n  \"_links\": {\n      \"self\": {\n        \"href\": \"/foo\"\n    }\n  }\n}\n```\n\nInstead of using the Document builder, you can handwrite the `HAL.Document`:\n\n```elixir\n%HAL.Document{\n  embeds: [\n    %HAL.Embed{\n      embed: %HAL.Document{embeds: [], links: [], properties: %{id: 18}},\n      resource: \"rad:podcast\"\n    }\n  ],\n  links: [%HAL.Link{href: \"/foo\", rel: \"self\", title: nil}],\n  properties: %{bar: \"baz\", foo: 42}\n}\n|\u003e Jason.encode!()\n```\n\n## License\n\nHAL is released under the MIT License - see the [LICENSE](https://github.com/podlove/hal/blob/master/LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpodlove%2Fhal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpodlove%2Fhal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpodlove%2Fhal/lists"}