Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Reddit Json Api Laravel Package

rennokki/reddit-json-api

A lightweight Laravel/PHP wrapper for Reddit's public JSON API. Fetch subreddits, posts, and comments without OAuth or API keys, making it easy to pull Reddit content into your application with a simple, expressive interface.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Treat 2.5.0 as a platform-support release, not a feature release. It upgrades the package to Illuminate 10.x, adds PHP 8.2 support, and drops PHP 8.0 and Illuminate 8.x.
  • Before upgrading, verify the app’s actual constraints:
    • composer why-not renoki-co/reddit-json-api ^2.5
    • Check composer.json for PHP and illuminate/* constraints.
    • Confirm whether the app is on Laravel/Illuminate 10.x. Do not assume Laravel 9 is supported just because the release notes only explicitly mention dropping Illuminate 8.x.
  • Install/upgrade in a branch:
    • composer require renoki-co/reddit-json-api:^2.5
    • Run the app test suite and any package-specific tests.
    • Clear cached config after deploy: php artisan config:clear.
  • Look first at:
    • The package README for the current client/facade API.
    • The published config file for base URI, User-Agent, and HTTP options.
    • The package composer.json to confirm PHP/Illuminate support.
    • Existing tests for examples of request faking and response parsing.
  • First practical use case: fetch hot/new posts from a subreddit on a schedule, normalize them into a local table, and render or search them internally. This package is best suited to read-only public Reddit JSON data, not authenticated write actions.

Implementation Patterns

  • Wrap the package client behind your own service or repository. Do not call the facade directly from controllers, views, or jobs. This keeps Reddit response quirks, caching, and rate-limit handling in one place.
  • Use a read-through cache pattern for public subreddit/list/comment responses:
    • Cache by endpoint, subreddit/user, sort, and pagination parameters.
    • Set a short TTL for hot/new listings and a longer TTL for relatively stable comment trees.
    • Serve cached or last-known-good data when Reddit returns 403, 429, or 5xx responses.
  • Prefer queued ingestion jobs for anything beyond a single user-triggered request. Poll subreddit listings or comment threads in jobs, normalize the response, and store the fields your app actually needs.
  • Normalize Reddit’s nested JSON shape early. Expect listing responses with data.children, kind, after, and before. Map posts/comments into your own DTOs or Eloquent models rather than passing raw arrays through the app.
  • Handle pagination explicitly. Store or pass after/before tokens where the package exposes them, and cap page counts in scheduled jobs to avoid runaway ingestion.
  • Use Laravel’s HTTP client fakes in tests. Build fixtures for listing, comment, empty, rate-limited, and malformed responses so your wrapper is tested without hitting Reddit.
  • Configure a descriptive User-Agent through environment/config, not hardcoded strings. Keep it stable and identifiable to your app.
  • Log request metadata for failed ingestion: endpoint, subreddit/user, status code, retry count, and whether cached data was served. Do not log full response bodies by default.
  • If the package exposes configurable HTTP options, bind those through config and keep retries/backoff in your wrapper so behavior is consistent across jobs and commands.

Gotchas and Tips

  • 2.5.0 is a breaking platform bump for older apps: PHP 8.0 and Illuminate 8.x are dropped. Check deployment images, CI matrices, and locked dependencies before merging.
  • “Added PHP 8.2” does not necessarily mean PHP 8.2 is required. Confirm the exact PHP constraint in composer.json; the practical minimum is likely PHP 8.1, but trust Composer over release-note shorthand.
  • Reddit’s public JSON endpoints are rate-limited and can return 403/429 without much warning. Always send a meaningful User-Agent, back off on 429, and degrade gracefully rather than retrying aggressively.
  • This package is for public JSON data. If you need OAuth, private subreddits, voting, posting, or moderation actions, use an authenticated Reddit API client instead.
  • Reddit response shapes are not a stable internal contract. Keep parsing tolerant of missing fields, deleted comments, promoted posts, and empty listings.
  • Watch pagination edge cases: after can be absent, listings can be empty, and repeated polling can duplicate posts. Use Reddit IDs as idempotency keys when storing.
  • Debug with Laravel HTTP client events or targeted logging around your wrapper, not by dumping full Reddit payloads in production. For tests, use Http::fake() and assert the outgoing URL/User-Agent where possible.
  • After deploying the upgrade, clear config and opcache as appropriate. If the package’s config file changed, re-publish and diff it rather than overwriting local customizations.
  • Prefer extension through your own wrapper, config, and HTTP client customization. Avoid editing vendor files; package internals may change across Illuminate upgrades.
  • Since 2.5.0 adds no obvious feature surface, do not rewrite working integrations. Focus the upgrade on compatibility checks, dependency constraints, and regression tests around rate-limit and error handling.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels