{"id":18981437,"url":"https://github.com/awncorp/api-client","last_synced_at":"2026-06-21T02:32:05.942Z","repository":{"id":77256341,"uuid":"300956561","full_name":"awncorp/api-client","owner":"awncorp","description":"HTTP API Thin-Client Abstraction","archived":false,"fork":false,"pushed_at":"2020-10-03T20:32:47.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-11T02:32:21.486Z","etag":null,"topics":["api-client","perl","perl5"],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awncorp.png","metadata":{"files":{"readme":"README","changelog":"CHANGES","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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-10-03T19:03:16.000Z","updated_at":"2022-07-24T20:54:26.000Z","dependencies_parsed_at":"2023-05-25T06:30:11.961Z","dependency_job_id":null,"html_url":"https://github.com/awncorp/api-client","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/awncorp/api-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awncorp%2Fapi-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awncorp%2Fapi-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awncorp%2Fapi-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awncorp%2Fapi-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awncorp","download_url":"https://codeload.github.com/awncorp/api-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awncorp%2Fapi-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34592050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api-client","perl","perl5"],"created_at":"2024-11-08T16:09:50.619Z","updated_at":"2026-06-21T02:32:05.921Z","avatar_url":"https://github.com/awncorp.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"NAME\n\n    API::Client\n\nABSTRACT\n\n    HTTP API Thin-Client Abstraction\n\nSYNOPSIS\n\n      package main;\n    \n      use API::Client;\n    \n      my $client = API::Client-\u003enew(url =\u003e 'https://httpbin.org');\n    \n      # $client-\u003eresource('post');\n    \n      # $client-\u003eupdate(json =\u003e {...});\n\nDESCRIPTION\n\n    This package provides an abstraction and method for rapidly developing\n    HTTP API clients. While this module can be used to interact with APIs\n    directly, API::Client was designed to be consumed (subclassed) by\n    higher-level purpose-specific API clients.\n\nTHIN CLIENT\n\n    The thin API client library is advantageous as it has complete API\n    coverage and can easily adapt to changes in the API with minimal\n    effort. As a thin-client superclass, this module does not map specific\n    HTTP requests to specific routines, nor does it provide parameter\n    validation, pagination, or other conventions found in typical API\n    client implementations; Instead, it simply provides a simple and\n    consistent mechanism for dynamically generating HTTP requests.\n    Additionally, this module has support for debugging and retrying API\n    calls as well as throwing exceptions when 4xx and 5xx server response\n    codes are returned.\n\nINTEGRATES\n\n    This package integrates behaviors from:\n\n    Data::Object::Role::Buildable\n\n    Data::Object::Role::Stashable\n\n    Data::Object::Role::Throwable\n\nLIBRARIES\n\n    This package uses type constraints from:\n\n    Types::Standard\n\nSCENARIOS\n\n    This package supports the following scenarios:\n\n building\n\n      # given: synopsis\n    \n      my $resource = $client-\u003eresource('get');\n    \n      # GET /get\n      my $get = $client-\u003eresource('get')-\u003edispatch;\n    \n      # HEAD /head\n      my $head = $client-\u003eresource('head')-\u003edispatch(\n        method =\u003e 'head'\n      );\n    \n      # PATCH /patch\n      my $patch = $client-\u003eresource('patch')-\u003edispatch(\n        method =\u003e 'patch'\n      );\n    \n      [$get, $head, $patch]\n\n    Building up an HTTP request is extremely easy, simply call the\n    \"resource\" to create a new object instance representing the API\n    endpoint you wish to issue a request against.\n\n chaining\n\n      # given: synopsis\n    \n      # https://httpbin.org/users\n      my $users = $client-\u003eresource('users');\n    \n      # https://httpbin.org/users/c09e91a\n      my $user = $client-\u003eresource('users', 'c09e91a');\n    \n      # https://httpbin.org/users/c09e91a\n      my $new_user = $users-\u003eresource('c09e91a');\n    \n      [$users, $user, $new_user]\n\n    Because each call to \"resource\" returns a new object instance\n    configured with a path (resource locator) based on the supplied\n    parameters, reuse and request isolation are made simple, i.e., you will\n    only need to configure the client once in your application.\n\n creating\n\n      # given: synopsis\n    \n      my $tx1 = $client-\u003eresource('post')-\u003ecreate(\n        json =\u003e {active =\u003e 1}\n      );\n    \n      # is equivalent to\n    \n      my $tx2 = $client-\u003eresource('post')-\u003edispatch(\n        method =\u003e 'post',\n        json =\u003e {active =\u003e 1}\n      );\n    \n      [$tx1, $tx2]\n\n    This example illustrates how you might create a new API resource.\n\n deleting\n\n      # given: synopsis\n    \n      my $tx1 = $client-\u003eresource('delete')-\u003edelete(\n        json =\u003e {active =\u003e 1}\n      );\n    \n      # is equivalent to\n    \n      my $tx2 = $client-\u003eresource('delete')-\u003edispatch(\n        method =\u003e 'delete',\n        json =\u003e {active =\u003e 1}\n      );\n    \n      [$tx1, $tx2]\n\n    This example illustrates how you might delete a new API resource.\n\n fetching\n\n      # given: synopsis\n    \n      my $tx1 = $client-\u003eresource('get')-\u003efetch(\n        query =\u003e {active =\u003e 1}\n      );\n    \n      # is equivalent to\n    \n      my $tx2 = $client-\u003eresource('get')-\u003edispatch(\n        method =\u003e 'get',\n        query =\u003e {active =\u003e 1}\n      );\n    \n      [$tx1, $tx2]\n\n    This example illustrates how you might fetch an API resource.\n\n subclassing\n\n      package Hookbin;\n    \n      use Data::Object::Class;\n    \n      extends 'API::Client';\n    \n      sub auth {\n        ['admin', 'secret']\n      }\n    \n      sub headers {\n        [['Accept', '*/*']]\n      }\n    \n      sub base {\n        ['https://httpbin.org/get']\n      }\n    \n      package main;\n    \n      my $hookbin = Hookbin-\u003enew;\n\n    This package was designed to be subclassed and provides hooks into the\n    client building and request dispatching processes. Specifically, there\n    are three useful hooks (i.e. methods, which if present are used to\n    build up the client object and requests), which are, the auth hook,\n    which should return a Tuple[Str, Str] which is used to configure the\n    basic auth header, the base hook which should return a Tuple[Str] which\n    is used to configure the base URL, and the headers hook, which should\n    return a ArrayRef[Tuple[Str, Str]] which are used to configure the HTTP\n    request headers.\n\n transacting\n\n      # given: synopsis\n    \n      my $tx1 = $client-\u003eresource('patch')-\u003epatch(\n        json =\u003e {active =\u003e 1}\n      );\n    \n      # is equivalent to\n    \n      my $tx2 = $client-\u003eresource('patch')-\u003edispatch(\n        method =\u003e 'patch',\n        json =\u003e {active =\u003e 1}\n      );\n    \n      [$tx1, $tx2]\n\n    An HTTP request is only issued when the \"dispatch\" method is called,\n    directly or indirectly. Those calls return a Mojo::Transaction object\n    which provides access to the request and response objects.\n\n updating\n\n      # given: synopsis\n    \n      my $tx1 = $client-\u003eresource('put')-\u003eupdate(\n        json =\u003e {active =\u003e 1}\n      );\n    \n      # is equivalent to\n    \n      my $tx2 = $client-\u003eresource('put')-\u003edispatch(\n        method =\u003e 'put',\n        json =\u003e {active =\u003e 1}\n      );\n    \n      [$tx1, $tx2]\n\n    This example illustrates how you might update a new API resource.\n\nATTRIBUTES\n\n    This package has the following attributes:\n\n debug\n\n      debug(Bool)\n\n    This attribute is read-only, accepts (Bool) values, and is optional.\n\n fatal\n\n      fatal(Bool)\n\n    This attribute is read-only, accepts (Bool) values, and is optional.\n\n logger\n\n      logger(InstanceOf[\"FlightRecorder\"])\n\n    This attribute is read-only, accepts (InstanceOf[\"FlightRecorder\"])\n    values, and is optional.\n\n name\n\n      name(Str)\n\n    This attribute is read-only, accepts (Str) values, and is optional.\n\n retries\n\n      retries(Int)\n\n    This attribute is read-only, accepts (Int) values, and is optional.\n\n timeout\n\n      timeout(Int)\n\n    This attribute is read-only, accepts (Int) values, and is optional.\n\n url\n\n      url(InstanceOf[\"Mojo::URL\"])\n\n    This attribute is read-only, accepts (InstanceOf[\"Mojo::URL\"]) values,\n    and is optional.\n\n user_agent\n\n      user_agent(InstanceOf[\"Mojo::UserAgent\"])\n\n    This attribute is read-only, accepts (InstanceOf[\"Mojo::UserAgent\"])\n    values, and is optional.\n\n version\n\n      version(Str)\n\n    This attribute is read-only, accepts (Str) values, and is optional.\n\nMETHODS\n\n    This package implements the following methods:\n\n create\n\n      create(Any %args) : InstanceOf[\"Mojo::Transaction\"]\n\n    The create method issues a POST request to the API resource represented\n    by the object.\n\n    create example #1\n\n        # given: synopsis\n      \n        $client-\u003eresource('post')-\u003ecreate(\n          json =\u003e {active =\u003e 1}\n        );\n\n delete\n\n      delete(Any %args) : InstanceOf[\"Mojo::Transaction\"]\n\n    The delete method issues a DELETE request to the API resource\n    represented by the object.\n\n    delete example #1\n\n        # given: synopsis\n      \n        $client-\u003eresource('delete')-\u003edelete;\n\n dispatch\n\n      dispatch(Str :$method = 'get', Any %args) : InstanceOf[\"Mojo::Transaction\"]\n\n    The dispatch method issues a request to the API resource represented by\n    the object.\n\n    dispatch example #1\n\n        # given: synopsis\n      \n        $client-\u003eresource('get')-\u003edispatch;\n\n    dispatch example #2\n\n        # given: synopsis\n      \n        $client-\u003eresource('post')-\u003edispatch(\n          method =\u003e 'post', body =\u003e 'active=1'\n        );\n\n    dispatch example #3\n\n        # given: synopsis\n      \n        $client-\u003eresource('get')-\u003edispatch(\n          method =\u003e 'get', query =\u003e {active =\u003e 1}\n        );\n\n    dispatch example #4\n\n        # given: synopsis\n      \n        $client-\u003eresource('post')-\u003edispatch(\n          method =\u003e 'post', json =\u003e {active =\u003e 1}\n        );\n\n    dispatch example #5\n\n        # given: synopsis\n      \n        $client-\u003eresource('post')-\u003edispatch(\n          method =\u003e 'post', form =\u003e {active =\u003e 1}\n        );\n\n    dispatch example #6\n\n        # given: synopsis\n      \n        $client-\u003eresource('put')-\u003edispatch(\n          method =\u003e 'put', json =\u003e {active =\u003e 1}\n        );\n\n    dispatch example #7\n\n        # given: synopsis\n      \n        $client-\u003eresource('patch')-\u003edispatch(\n          method =\u003e 'patch', json =\u003e {active =\u003e 1}\n        );\n\n    dispatch example #8\n\n        # given: synopsis\n      \n        $client-\u003eresource('delete')-\u003edispatch(\n          method =\u003e 'delete', json =\u003e {active =\u003e 1}\n        );\n\n fetch\n\n      fetch(Any %args) : InstanceOf[\"Mojo::Transaction\"]\n\n    The fetch method issues a GET request to the API resource represented\n    by the object.\n\n    fetch example #1\n\n        # given: synopsis\n      \n        $client-\u003eresource('get')-\u003efetch;\n\n patch\n\n      patch(Any %args) : InstanceOf[\"Mojo::Transaction\"]\n\n    The patch method issues a PATCH request to the API resource represented\n    by the object.\n\n    patch example #1\n\n        # given: synopsis\n      \n        $client-\u003eresource('patch')-\u003epatch(\n          json =\u003e {active =\u003e 1}\n        );\n\n prepare\n\n      prepare(Object $ua, Object $tx, Any %args) : Object\n\n    The prepare method acts as a before hook triggered before each request\n    where you can modify the transactor objects.\n\n    prepare example #1\n\n        # given: synopsis\n      \n        require Mojo::UserAgent;\n        require Mojo::Transaction::HTTP;\n      \n        $client-\u003eprepare(\n          Mojo::UserAgent-\u003enew,\n          Mojo::Transaction::HTTP-\u003enew\n        );\n\n process\n\n      process(Object $ua, Object $tx, Any %args) : Object\n\n    The process method acts as an after hook triggered after each response\n    where you can modify the transactor objects.\n\n    process example #1\n\n        # given: synopsis\n      \n        require Mojo::UserAgent;\n        require Mojo::Transaction::HTTP;\n      \n        $client-\u003eprocess(\n          Mojo::UserAgent-\u003enew,\n          Mojo::Transaction::HTTP-\u003enew\n        );\n\n resource\n\n      resource(Str @segments) : Object\n\n    The resource method returns a new instance of the object for the API\n    resource endpoint specified.\n\n    resource example #1\n\n        # given: synopsis\n      \n        $client-\u003eresource('status', 200);\n\n serialize\n\n      serialize() : HashRef\n\n    The serialize method serializes and returns the object as a hashref.\n\n    serialize example #1\n\n        # given: synopsis\n      \n        $client-\u003eserialize;\n\n update\n\n      update(Any %args) : InstanceOf[\"Mojo::Transaction\"]\n\n    The update method issues a PUT request to the API resource represented\n    by the object.\n\n    update example #1\n\n        # given: synopsis\n      \n        $client-\u003eresource('put')-\u003eupdate(\n          json =\u003e {active =\u003e 1}\n        );\n\nAUTHOR\n\n    Al Newkirk, awncorp@cpan.org\n\nLICENSE\n\n    Copyright (C) 2011-2019, Al Newkirk, et al.\n\n    This is free software; you can redistribute it and/or modify it under\n    the terms of the The Apache License, Version 2.0, as elucidated in the\n    \"license file\"\n    \u003chttps://github.com/iamalnewkirk/api-client/blob/master/LICENSE\u003e.\n\nPROJECT\n\n    Wiki \u003chttps://github.com/iamalnewkirk/api-client/wiki\u003e\n\n    Project \u003chttps://github.com/iamalnewkirk/api-client\u003e\n\n    Initiatives \u003chttps://github.com/iamalnewkirk/api-client/projects\u003e\n\n    Milestones \u003chttps://github.com/iamalnewkirk/api-client/milestones\u003e\n\n    Contributing\n    \u003chttps://github.com/iamalnewkirk/api-client/blob/master/CONTRIBUTE.md\u003e\n\n    Issues \u003chttps://github.com/iamalnewkirk/api-client/issues\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawncorp%2Fapi-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawncorp%2Fapi-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawncorp%2Fapi-client/lists"}