{"id":20244773,"url":"https://github.com/renoki-co/reddit-json-api","last_synced_at":"2025-04-10T20:47:24.776Z","repository":{"id":36988966,"uuid":"166289783","full_name":"renoki-co/reddit-json-api","owner":"renoki-co","description":"Reddit JSON API is a PHP wrapper for handling JSON information from public subreddits.","archived":false,"fork":false,"pushed_at":"2023-12-11T01:01:22.000Z","size":103,"stargazers_count":20,"open_issues_count":4,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T18:21:17.785Z","etag":null,"topics":["api","laravel","pagination","php","php-wrapper","reddit","reddit-json-api","subreddits","wrapper"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/renoki-co.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-17T20:10:50.000Z","updated_at":"2023-12-22T03:57:08.000Z","dependencies_parsed_at":"2023-02-19T02:45:39.669Z","dependency_job_id":null,"html_url":"https://github.com/renoki-co/reddit-json-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/renoki-co%2Freddit-json-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renoki-co%2Freddit-json-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renoki-co%2Freddit-json-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renoki-co%2Freddit-json-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/renoki-co","download_url":"https://codeload.github.com/renoki-co/reddit-json-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248295530,"owners_count":21080125,"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":["api","laravel","pagination","php","php-wrapper","reddit","reddit-json-api","subreddits","wrapper"],"created_at":"2024-11-14T09:17:21.387Z","updated_at":"2025-04-10T20:47:24.759Z","avatar_url":"https://github.com/renoki-co.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![CI](https://github.com/renoki-co/reddit-json-api/workflows/CI/badge.svg?branch=master)\n[![codecov](https://codecov.io/gh/renoki-co/reddit-json-api/branch/master/graph/badge.svg)](https://codecov.io/gh/renoki-co/reddit-json-api/branch/master)\n[![StyleCI](https://github.styleci.io/repos/166289783/shield?branch=master)](https://github.styleci.io/repos/166289783)\n[![Latest Stable Version](https://poser.pugx.org/rennokki/reddit-json-api/v/stable)](https://packagist.org/packages/rennokki/reddit-json-api)\n[![Total Downloads](https://poser.pugx.org/rennokki/reddit-json-api/downloads)](https://packagist.org/packages/rennokki/reddit-json-api)\n[![Monthly Downloads](https://poser.pugx.org/rennokki/reddit-json-api/d/monthly)](https://packagist.org/packages/rennokki/reddit-json-api)\n[![License](https://poser.pugx.org/rennokki/reddit-json-api/license)](https://packagist.org/packages/rennokki/reddit-json-api)\n\nReddit JSON API is a PHP wrapper for handling JSON information from public subreddits.\n\n## 🚀 Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require rennokki/reddit-json-api\n```\n\n## 🙌 Usage\n\n```php\nuse Rennokki\\RedditApi\\Reddit;\n\n$app = Reddit::app(\n    'renoki-co/reddit-json-api',\n    '2.0',\n    'web',\n    'someusername'\n);\n\n$subreddit = Reddit::subreddit(\n    'funny', // subreddit name\n    $app\n);\n\n$posts = $subreddit-\u003eget();\n\nforeach ($posts as $post) {\n    $id = $post['id'];\n}\n```\n\nWhen retrieving posts, the results are wrapped in a `Rennokki\\RedditApi\\RedditList` class. This class is based on Laravel Collection and you can pipeline actions on it more easily. Please see [Laravel Collections documentantion](https://laravel.com/docs/master/collections).\n\n## Pagination\n\nFor pagination purposes, you shall call `nextPage()` from the previous `$posts`:\n\n```php\n$subreddit = Reddit::subreddit('funny', $app);\n\n$posts = $subreddit-\u003eget();\n\n$nextPageOfPosts = $posts-\u003enextPage();\n```\n\n## Sorting\n\nReddit allows sorting by posts type. The currently used ones are:\n\n```php\npublic static $sorts = [\n    'hot', 'new', 'controversial', 'top', 'rising',\n];\n```\n\nTo apply the sorting, you should call `sort()`:\n\n```php\n$subreddit = Reddit::subreddit('funny', $app);\n\n$subreddit-\u003esort('top');\n```\n\n## Time Filtering\n\nSame as sorting, time filters are only a few:\n\n```php\npublic static $times = [\n    'hour', 'day', 'week', 'month', 'year', 'all',\n];\n```\n\n```php\n$subreddit = Reddit::subreddit('funny', $app);\n\n// Top, all time sorting.\n$subreddit\n    -\u003esort('top')\n    -\u003etime('all');\n```\n\n## Limit\n\nBy default, each call gives you `20` posts.\n\n```php\n$subreddit = Reddit::subreddit('funny', $app);\n\n$subreddit-\u003esetLimit(100);\n```\n\n## Debugging\n\nIf you wish to inspect the URL that is being called, you ca do so:\n\n```php\n$subreddit = Reddit::subreddit('funny', $app);\n\n$subreddit\n    -\u003esetLimit(30)\n    -\u003esort('top')\n    -\u003etime('week');\n\n$url = $subreddit-\u003egetCallableUrl();\n```\n\n## 🐛 Testing\n\n``` bash\nvendor/bin/phpunit\n```\n\n## 🤝 Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## 🔒  Security\n\nIf you discover any security related issues, please email alex@renoki.org instead of using the issue tracker.\n\n## 🎉 Credits\n\n- [Alex Renoki](https://github.com/rennokki)\n- [All Contributors](../../contributors)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenoki-co%2Freddit-json-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frenoki-co%2Freddit-json-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenoki-co%2Freddit-json-api/lists"}