{"id":13563033,"url":"https://github.com/franjid/api-wrapper-bundle","last_synced_at":"2025-10-07T03:29:21.648Z","repository":{"id":62507018,"uuid":"76951748","full_name":"franjid/api-wrapper-bundle","owner":"franjid","description":"Easily consume API's from your Symfony project","archived":false,"fork":false,"pushed_at":"2017-05-11T18:58:05.000Z","size":13,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T18:54:56.951Z","etag":null,"topics":["api","api-wrapper","bundle","php","symfony","wrapper"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/franjid.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":"2016-12-20T11:42:00.000Z","updated_at":"2022-02-28T14:47:15.000Z","dependencies_parsed_at":"2022-11-02T12:31:32.691Z","dependency_job_id":null,"html_url":"https://github.com/franjid/api-wrapper-bundle","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/franjid/api-wrapper-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franjid%2Fapi-wrapper-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franjid%2Fapi-wrapper-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franjid%2Fapi-wrapper-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franjid%2Fapi-wrapper-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/franjid","download_url":"https://codeload.github.com/franjid/api-wrapper-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franjid%2Fapi-wrapper-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278715506,"owners_count":26033295,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"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","api-wrapper","bundle","php","symfony","wrapper"],"created_at":"2024-08-01T13:01:14.492Z","updated_at":"2025-10-07T03:29:21.634Z","avatar_url":"https://github.com/franjid.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# API Wrapper Bundle for Symfony\n\n[![Build Status](https://travis-ci.org/franjid/api-wrapper-bundle.svg?branch=master)](https://travis-ci.org/franjid/api-wrapper-bundle)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/franjid/api-wrapper-bundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/franjid/api-wrapper-bundle/)\n[![Code Coverage](https://scrutinizer-ci.com/g/franjid/api-wrapper-bundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/franjid/api-wrapper-bundle/)\n\nThe aim of this bundle is to act as a wrapper for any API library you want to use in Symfony. In this case with Guzzle, the most popular PHP HTTP client library.\n\nIt has never been so easy to consume an API than with this bundle.\n\n## What can you find?\n\n##### Api.php\n\nThis is where the encapsulation magic happens.\n\nIt has only one method **send** that sends the proper request to the API.\n\n##### ApiClientFactory.php\nUsed to create all different API clients. When defined it requires a base uri for the API as a simple string or an array of different url's. In case that an array is given, the factory will choose one of them randomly. This is kind of a basic basic load balancer implemented because of reasons.\n\n##### ApiRequest.php\nIt has to be used to send requests to API's. Using the different methods you will be able to set the request method (GET, POST, etc), set headers, set the endpoint, etc.\n\n##### ApiResponse.php\nObject returned when successfully calling **send** method in *Api*. You can get the response status code, headers or body.\n\n## How to use it\n\nFirst things first, install package via composer:\n```\ncomposer require franjid/api-wrapper-bundle\n```\n\nAnd add the bundle to your AppKernel.php\n```\nnew \\Franjid\\ApiWrapperBundle\\ApiWrapperBundle(),\n```\n\n### Example: adding an API for [Xkcd API](https://xkcd.com/json.html)\n\nYou can check a project with example code using the bundle in [this repository](https://github.com/franjid/api-wrapper-bundle-example)\n\nFirst step is to define the API Client in your services config file\n```\n    ApiClientXkcd:\n        class: ApiClientXkcd\n        factory: [@ApiWrapperBundle.Component.Api.ApiClientFactory, createApiClient]\n        arguments:\n            - %apiXkcdBaseURI%\n```\nThat will create the *ApiClientXkcd* taking the parameter *apiXkcdBaseURI* and injecting it so we have a base URI.\n\napiXkcdBaseURI should be in the format\n```\n    apiXkcdBaseURI: 'http://xkcd.com/'\n```\n\nNow is time to create the interface, then the service class and add it to your services config file\n```\n    Service.Api.ApiXkcdServiceInterface:\n        class: AppBundle\\Service\\Api\\ApiXkcdService\n        arguments:\n            - @ApiClientXkcd\n```\n\nAt this moment you're ready to go for adding your awesome methods that will call the API.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranjid%2Fapi-wrapper-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffranjid%2Fapi-wrapper-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranjid%2Fapi-wrapper-bundle/lists"}