{"id":14969764,"url":"https://github.com/aternosorg/php-hangar-api","last_synced_at":"2026-02-25T22:02:28.214Z","repository":{"id":153589619,"uuid":"629952821","full_name":"aternosorg/php-hangar-api","owner":"aternosorg","description":"PHP Client for the Hangar API. This client is based on the openapi spec.","archived":false,"fork":false,"pushed_at":"2024-01-26T13:39:34.000Z","size":517,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-28T04:52:04.779Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/aternosorg.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-19T11:10:41.000Z","updated_at":"2024-07-17T15:31:26.128Z","dependencies_parsed_at":"2024-07-17T15:41:31.206Z","dependency_job_id":null,"html_url":"https://github.com/aternosorg/php-hangar-api","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aternosorg%2Fphp-hangar-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aternosorg%2Fphp-hangar-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aternosorg%2Fphp-hangar-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aternosorg%2Fphp-hangar-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aternosorg","download_url":"https://codeload.github.com/aternosorg/php-hangar-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219863300,"owners_count":16555950,"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-09-24T13:42:20.124Z","updated_at":"2025-10-26T09:30:58.028Z","avatar_url":"https://github.com/aternosorg.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Aternos/php-hangar-api\nAn API client for the Hangar API written in PHP. This client is a combination of\ncode generated by OpenAPI Generator and some wrappers around it to improve the\nusability.\n\nThe generated code can be found in `lib/Api` and `lib/Model`. It is recommended\nto use the Wrappers in `lib/Client` instead of the generated code.\n\n## Installation\nInstall the package via composer:\n```bash\ncomposer require aternos/hangar-api\n```\n\n## Usage\n\nThe main entry point for the API is the `HangarAPIClient` class.\n```php\n\u003c?php\nuse Aternos\\HangarApi\\Client\\HangarAPIClient;\n\n// create an API client. This is the main entry point for the API\n$hangarClient = new HangarAPIClient();\n\n// set a user agent (recommended)\n$hangarClient-\u003esetUserAgent('aternos/php-hangar-api-example');\n\n// set an api key (optional)\n$hangarClient-\u003esetApiKey(\"api-key\");\n```\nThe API Key is only required for non-public requests but if it is provided, it will be used for all requests.\n\n## Result Lists\nMost methods return a paginated result list which contains a list of results on the current page and methods to\nnavigate to the next and previous page. The result list implements `Iterator`, `ArrayAccess` and `Countable` so\nyou can use it like an array. It also has a `getResults()` method which returns the underlying array of results.\n\n### Searching for Projects\n```php\n$projects = $hangarClient-\u003egetProjects();\n\nforeach ($project as $project) {\n    // like most other methods, this method returns a wrapper\n    // you can use the getData() method to get the project data\n    echo $project-\u003egetData()-\u003egetName() . PHP_EOL;\n}\n\n$projects = $projects-\u003egetNextPage();\n\nforeach ($projects as $project) {\n    echo $project-\u003egetData()-\u003egetName() . PHP_EOL;\n}\n```\n\n### Search for Projects with Options\nYou can apply filters and change the sort order when searching for projects.\nAll options are optional and can be combined.\n```php\nuse \\Aternos\\HangarApi\\Client\\Options\\ProjectSearch\\ProjectSearchOptions;\nuse \\Aternos\\HangarApi\\Client\\Options\\ProjectCategory;\nuse \\Aternos\\HangarApi\\Client\\Options\\ProjectSearch\\ProjectSortField;\n\n$options = new ProjectSearchOptions();\n$options-\u003esetCategory(ProjectCategory::ADMIN_TOOLS);\n$options-\u003esetQuery(\"mclogs\");\n$options-\u003esetSortField(ProjectSortField::UPDATED);\n$projects = $hangarClient-\u003egetProjects($options);\n```\n\n## Getting Additional Project Data\nThe Project wrapper provides methods to fetch additional data about the project.\n```php\n// get a specific project\n$project = $hangarClient-\u003egetProject(\"mclogs\");\n\n// get versions of the project (paginated)\n$versions = $project-\u003egetVersions();\n\n// get a specific version\n$version = $project-\u003egetVersion(\"2.6.2\");\n\n// get the owner of the project\n$owner = $project-\u003egetOwner();\n\n// get the members of the project (paginated)\n$members = $project-\u003egetMembers();\n\n// get the people who starred the project (paginated)\n$stargazers = $project-\u003egetStargazers();\n\n// get the people who are watching the project (paginated)\n$watchers = $project-\u003egetWatchers();\n```\n\n## Versions\n```php\n// get versions of a project by name (paginated)\n$versions = $hangarClient-\u003egetProjectVersions(\"mclogs\");\n\n// get the versions from a project (paginated)\n$versions = $project-\u003egetVersions();\n\n// get a specific version of a project by name\n$version = $hangarClient-\u003egetVersion(\"mclogs\", \"2.6.2\");\n\n// get a specific version of a project\n$version = $project-\u003egetVersion(\"2.6.2\");\n\n// get the daily stats of the version\n$stats = $version-\u003egetDailyStats();\nforeach ($stats as $date =\u003e $stat) {\n    echo $stat-\u003egetData()-\u003egetDownloads() . \" Downloads and on \" $date . PHP_EOL;\n}\n```\n\n## Users\n```php\n// get a user\n$user = $hangarClient-\u003egetUser(\"Aternos\");\n\n// get all projects of a user (paginated)\n$projects = $user-\u003egetProjects();\n\n// get the projects a user has starred (paginated)\n$starredProjects = $user-\u003egetStarredProjects();\n\n// get the projects a user is watching (paginated)\n$watchedProjects = $user-\u003egetWatchedProjects();\n```\n\n## Project Pages\n```php\n// get the main page of a project\n$page = $hangarClient-\u003egetProjectMainPage(\"mclogs\");\n\n// get other pages\n$page = $hangarClient-\u003egetProjectPage(\"mclogs\", \"Config\");\n\n// get a page from a project\n$page = $project-\u003egetPage(\"Config\");\n\n// edit a page\n$page-\u003esetContent(\"New content\");\n$page-\u003esave();\n```\n\n## Updating the generated code\nThe generated code can be updated by installing the [openapi generator](https://openapi-generator.tech/docs/installation) running the following command:\n```bash\nopenapi-generator-cli generate -c config.yaml\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faternosorg%2Fphp-hangar-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faternosorg%2Fphp-hangar-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faternosorg%2Fphp-hangar-api/lists"}