{"id":41795694,"url":"https://github.com/raicem/reddit-public-api-wrapper","last_synced_at":"2026-01-25T05:30:21.592Z","repository":{"id":62532784,"uuid":"145456629","full_name":"raicem/reddit-public-api-wrapper","owner":"raicem","description":"A simple wrapper for Reddit's public API","archived":false,"fork":false,"pushed_at":"2018-08-20T18:53:55.000Z","size":19,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-19T09:53:00.700Z","etag":null,"topics":["api-wrapper","php","reddit"],"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/raicem.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-20T18:37:32.000Z","updated_at":"2024-06-27T08:32:33.000Z","dependencies_parsed_at":"2022-11-02T14:33:08.859Z","dependency_job_id":null,"html_url":"https://github.com/raicem/reddit-public-api-wrapper","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/raicem/reddit-public-api-wrapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raicem%2Freddit-public-api-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raicem%2Freddit-public-api-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raicem%2Freddit-public-api-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raicem%2Freddit-public-api-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raicem","download_url":"https://codeload.github.com/raicem/reddit-public-api-wrapper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raicem%2Freddit-public-api-wrapper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28744429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T05:12:38.112Z","status":"ssl_error","status_checked_at":"2026-01-25T05:04:50.338Z","response_time":113,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-wrapper","php","reddit"],"created_at":"2026-01-25T05:30:20.990Z","updated_at":"2026-01-25T05:30:21.586Z","avatar_url":"https://github.com/raicem.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Reddit Public API PHP Wrapper\n===\n\nReddit provides a very convenient access to its data just by adding `.json` to the end of normal URLs. For example, `https://www.reddit.com/r/formula1.json` will present you the json response.\n\nThis is a very simple wrapper around this feature of Reedit. Thies to grant easy access to subreddit and user data. \n\n### 1. Installation\n\nInstall it as a dependency using [Composer](https://getcomposer.org/)\n\n```bash\ncomposer require raicem/reddit-public-api-wrapper\n```\n\n### 2. Instantiate\n```php\n\nuse RedditWrapper\\Wrapper;\nuse RedditWrapper\\WrapperClient;\n\n$wrapper = new Wrapper(new WrapperClient());\n\n```\n\n### 3. Queries\n#### 3.1. Subreddit Query\nFetches information about a certain subreddit.\n\n```php\n\nuse RedditWrapper\\Queries\\SubredditQuery;\nuse RedditWrapper\\Enums\\SubredditSort;\nuse RedditWrapper\\Enums\\SubredditSortTime;\n\n$query = new SubredditQuery([\n    'subreddit' =\u003e 'formula1',\n]);\n\n$response = $wrapper-\u003efetch($query);\n\n```\n\nYou may add sort options to your query for best, top, rising, controversial posts in a subreddit.\nYou may use the constants provided with the `RedditWrapper\\Enums\\SubredditSort` and `RedditWrapper\\Enums\\SubredditSortTime`.\n\n```php\n\nuse RedditWrapper\\Queries\\SubredditQuery;\nuse RedditWrapper\\Enums\\SubredditSort;\nuse RedditWrapper\\Enums\\SubredditSortTime;\n\n$query = new SubredditQuery([\n    'subreddit' =\u003e 'formula1',\n    'sort' =\u003e SubredditSort::TOP,\n    'sortTime' =\u003e SubredditSortTime::WEEK,\n]);\n\n$response = $wrapper-\u003efetch($query);\n\n```\n\n#### 3.2. User Query\n\nFetches the feed belonging to a user.\n\n```php\n\nuse RedditWrapper\\Queries\\UserQuery;\n\n$query = new UserQuery([\n    'username' =\u003e 'unidan',\n]);\n\n$response = $wrapper-\u003efetch($query);\n\n```\n\nAll of these queries extends the `QueryInterface` in the package. So you can create your own query implementing `QueryInterface` in your code base and then provide it to the `Wrapper`.\n\n### 4. Magic Stuff\n#### 4.1. __call method on the Wrapper\n\nI believe the main function of this library will be to fetch subreddit information. I wanted to streamline that functionality as much as possible. \n\nSo without creating a new query, you may call the subreddit's name as a method on this wrapper.\n\n```php\n\nuse RedditWrapper\\Wrapper;\nuse RedditWrapper\\WrapperClient;\n\n$wrapper = new Wrapper(new WrapperClient());\n\n$response = $wrapper-\u003eformula1();\n\n```\n#### 4.2. `fetchSimple` method on Wrapper\nWhen fetching subreddit information, Reddit sends a lot of information that is probaby not neccessery. The default response can very difficult to get through. `fetchSimple` method removes all the clutter and tries to present response with only more general values.\n\n```php\n\n$query = new SubredditQuery([\n    'subreddit' =\u003e 'formula1',\n    'sort' =\u003e SubredditSort::TOP,\n    'sortTime' =\u003e SubredditSortTime::WEEK,\n]);\n\n$response = $wrapper-\u003efetchSimple($query);\n\n```\n\n`fetchSimple` method returns these values. This method only works for `SubredditQuery` instances.\n\n| Value        |\n| ------------ |\n| title        |\n| id           |\n| thumbnail    |\n| permalink    |\n| num_comments |\n| score        |\n| created      |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraicem%2Freddit-public-api-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraicem%2Freddit-public-api-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraicem%2Freddit-public-api-wrapper/lists"}