{"id":22546599,"url":"https://github.com/prx/prx_access-elixir","last_synced_at":"2025-10-05T00:30:12.524Z","repository":{"id":57537682,"uuid":"247829886","full_name":"PRX/prx_access-elixir","owner":"PRX","description":"Elixir client package for PRX APIs","archived":false,"fork":false,"pushed_at":"2020-04-08T20:19:56.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-04T05:22:48.884Z","etag":null,"topics":[],"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/PRX.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":"2020-03-16T22:38:32.000Z","updated_at":"2020-04-08T20:19:58.000Z","dependencies_parsed_at":"2022-09-07T16:41:15.114Z","dependency_job_id":null,"html_url":"https://github.com/PRX/prx_access-elixir","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PRX/prx_access-elixir","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PRX%2Fprx_access-elixir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PRX%2Fprx_access-elixir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PRX%2Fprx_access-elixir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PRX%2Fprx_access-elixir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PRX","download_url":"https://codeload.github.com/PRX/prx_access-elixir/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PRX%2Fprx_access-elixir/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260769485,"owners_count":23060115,"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-12-07T15:08:19.400Z","updated_at":"2025-10-05T00:30:07.415Z","avatar_url":"https://github.com/PRX.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PrxAccess\n\n[![Hex.pm](https://img.shields.io/hexpm/v/prx_access.svg)](https://hex.pm/packages/prx_access)\n[![Hex.pm](https://img.shields.io/hexpm/dw/prx_access.svg)](https://hex.pm/packages/prx_access)\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](LICENSE)\n\nElixir client library for accessing PRX [HAL](https://en.wikipedia.org/wiki/Hypertext_Application_Language) APIs.\n\n## Installation\n\nAdd the package to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:prx_access, \"~\u003e 0.2.0\"}\n  ]\nend\n```\n\n## Usage\n\nTo make requests against the a PRX API host, just provide the hostname and\nstart navigating:\n\n```elixir\n{:ok, root} = PrxAccess.root(\"feeder.prx.org\")\n\n# list link rels on this root document\n{:ok, rels} = PrxAccess.rels(root)\n\n# follow one of them!\n{:ok, podcasts} = PrxAccess.follow(root, \"prx:podcasts\", page: 1, per: 1)\nIO.puts(podcasts.attributes[\"count\"])\nIO.puts(podcasts.attributes[\"total\"])\n\n# get items from this page\n{:ok, items} = PrxAccess.follow(podcasts, \"prx:items\")\nEnum.each(items, fn(i) -\u003e IO.puts(i.attributes[\"title\"]) end)\n\n# follow off an item - woh, we're in CMS now!\n{:ok, account} = hd(items) |\u003e PrxAccess.follow(\"prx:account\")\nIO.puts(podcasts._url) # https://feeder.prx.org/api/v1/podcasts?page=1\u0026per=1\nIO.puts(account._url) # https://cms.prx.org/api/v1/accounts/5678\n```\n\n### Authorization\n\nTo make an authorized request, you'll need a PRX client_id and client_secret\nfor [id.prx.org](https://github.com/PRX/id.prx.org).\n\n```elixir\nauth_options = [\n  account: \"optional account_id for restricted token\",\n  scope: \"optional scope for restricted token\",\n  id_host: \"id.staging.prx.tech\",\n  client_id: \"my-client-id\",\n  client_secret: \"my-client-secret\"\n]\n{:ok, root} = PrxAccess.root(\"cms.staging.prx.tech\", auth_options)\n\n# or maybe you want the /api/v1/authorization entry point\n{:ok, auth_root} = PrxAccess.follow(\"/api/v1/authorization\")\n\n# or go directly there\n{:ok, auth_direct} = PrxAccess.get(\"https://cms.staging.prx.tech/api/v1/authorization\", auth_options)\n```\n\n### Chaining Requests\n\nIt's easy to chain together a bunch of HAL links, using elixir pipes.  If any of\nyour resources return a non-200, you'll get a `%PrxAccess.Error{}` returned for\nany subsequent link-follows:\n\n```elixir\n{:ok, podcast} = PrxAccess.root(\"feeder.prx.org\")\n  |\u003e PrxAccess.follow(\"prx:podcast\", id: 70)\n\n# or an error\n{:error, err} = PrxAccess.root(\"feeder.prx.org\")\n  |\u003e PrxAccess.follow(\"prx:podcast\", id: 70)\n  |\u003e PrxAccess.follow(\"prx:whatev\")\n  |\u003e PrxAccess.follow(\"prx:these\")\n  |\u003e PrxAccess.follow(\"prx:arenot\")\n  |\u003e PrxAccess.follow(\"prx:called\")\n\nIO.inspect(err)\n# %PrxAccess.Error{\n#   status: 200,\n#   url: \"https://feeder.prx.org/api/v1/podcasts/70\",\n#   message: \"rel prx:whatev not found\"\n# }\n```\n\n## License\n\n[MIT License](LICENSE)\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprx%2Fprx_access-elixir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprx%2Fprx_access-elixir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprx%2Fprx_access-elixir/lists"}