crawlora-reddit 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c6a6f2b03f805609edca6d5ed3c41c060326686c769988aca61786cf67da963
4
- data.tar.gz: db4b522ea3e45343af2c00ab9d2e52bff3c9a23ad2e5bc3405f26fb30f839fe3
3
+ metadata.gz: bd335fb8738ac4f6426210045ca2da771e3ebaa27667f5755a2882508e7aadc3
4
+ data.tar.gz: 98cee1e6f1a8c9a9c6ef59b65a23fc0c145f05d3d5e4ce152c7f566af0c53582
5
5
  SHA512:
6
- metadata.gz: 57e92163fadfe3cf1170b01a94878e452cc163b2f0f8a25eff31517659c729993e3c6935ffb546fea595d98f95f36a546cd13770464203b2ca4a476af07f445f
7
- data.tar.gz: ff0c8f3219edaafe14f4fc1f81242e9e4be20b2ba02cdcd316426112d77f342f7994d8660972ef629c71917d568a2af8878f5d8869ce115af42fe57ae697fbcf
6
+ metadata.gz: 0e21572cc86ad7fc2b7e87c09ff56ccfd6d7d52356225b0be372b83ec34ef3c730fce4b40dcf08daaf8ef01524541688271414e6c205ec2b5ce005f911ff3339
7
+ data.tar.gz: d847189d240b5617e06eb85eb2b1bea83470f0faaa26a90141cb2b9e633689116be115a6fe5026a49ce06b16bf6c130f1123342cb1aebf019fd6cbd856d43be4
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Crawlora Reddit Ruby client
1
+ # Crawlora Reddit API client for Ruby (`crawlora-reddit`)
2
2
 
3
- This gem calls the Crawlora hosted API at `https://api.crawlora.net/api/v1`. It does not call or scrape Reddit directly. Requests require your Crawlora API key and use your account's service plan.
3
+ This Ruby gem calls Crawlora's hosted Reddit API at `https://api.crawlora.net/api/v1`. It exposes 12 endpoints covering search, post and comment details, subreddit feeds, user history, domain listings, trends, and leads; it does not call or scrape Reddit directly. Requests require your Crawlora API key and use your account's service plan.
4
4
 
5
5
  ## Install
6
6
 
@@ -30,4 +30,23 @@ client.close
30
30
 
31
31
  Client options include `api_key`, `base_url`, and `timeout`. Ruby stdlib provides the HTTP and JSON support.
32
32
 
33
+ ## Supported Reddit API endpoints
34
+
35
+ Browse every route included in this gem. The [endpoint reference](https://github.com/Crawlora-org/crawlora-reddit/blob/main/docs/usage.md) includes parameter and response details.
36
+
37
+ | Method | Endpoint | API operation | Description |
38
+ | --- | --- | --- | --- |
39
+ | `GET` | `/reddit/comments/{id}` | `reddit-comments` | Get Reddit post comments |
40
+ | `GET` | `/reddit/domain/{domain}/posts` | `reddit-domain-posts` | List Reddit domain posts |
41
+ | `GET` | `/reddit/leads` | `reddit-leads` | Find Reddit buying-intent leads |
42
+ | `GET` | `/reddit/post/{id}` | `reddit-post` | Get Reddit post |
43
+ | `GET` | `/reddit/search` | `reddit-search` | Search Reddit posts |
44
+ | `GET` | `/reddit/subreddit/{subreddit}/about` | `reddit-subreddit-about` | Get Reddit subreddit metadata |
45
+ | `GET` | `/reddit/subreddit/{subreddit}/comments` | `reddit-subreddit-comments` | List Reddit subreddit comments |
46
+ | `GET` | `/reddit/subreddit/{subreddit}/posts` | `reddit-subreddit-posts` | List Reddit subreddit posts |
47
+ | `GET` | `/reddit/subreddits/posts` | `reddit-subreddits-posts` | List Reddit multi-subreddit posts |
48
+ | `GET` | `/reddit/trends` | `reddit-trends` | List Reddit trends |
49
+ | `GET` | `/reddit/user/{username}/comments` | `reddit-user-comments` | List Reddit user comments |
50
+ | `GET` | `/reddit/user/{username}/posts` | `reddit-user-posts` | List Reddit user posts |
51
+
33
52
  See [Crawlora](https://crawlora.net/?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=reddit-ruby-homepage), the [API documentation](https://crawlora.net/docs?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=reddit-ruby-api-docs), and [the package repository](https://github.com/Crawlora-org/crawlora-reddit) for account setup, the API operation reference, and release history.
@@ -19,7 +19,7 @@ module Crawlora
19
19
  end
20
20
 
21
21
  OPERATIONS = JSON.parse(<<~'JSON').freeze
22
- {"reddit-comments": {"id": "reddit-comments", "method": "GET", "params": [{"description": "Reddit post id or t3_ id", "in": "path", "name": "id", "required": true, "type": "string", "x-example": "1tka90t"}, {"default": "confidence", "description": "Comment order: confidence, top, new, controversial, old, or qa. Applied to the anonymous HTML request when metrics are enabled.", "enum": ["confidence", "top", "new", "controversial", "old", "qa"], "in": "query", "name": "sort", "type": "string"}, {"description": "Maximum comments returned, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"default": 3, "description": "Maximum flat comment depth returned in metrics mode.", "in": "query", "name": "depth", "type": "integer"}, {"default": false, "description": "Include public post and per-comment engagement metrics; costs 3 credits instead of 1", "in": "query", "name": "include_metrics", "type": "boolean"}], "path": "/reddit/comments/{id}", "pathParams": ["id"], "produces": ["application/json"], "queryParams": [{"enum": ["confidence", "top", "new", "controversial", "old", "qa"], "in": "query", "name": "sort", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "depth", "type": "integer"}, {"in": "query", "name": "include_metrics", "type": "boolean"}], "security": ["ApiKeyAuth"]}, "reddit-domain-posts": {"id": "reddit-domain-posts", "method": "GET", "params": [{"description": "Domain hostname, without scheme or path", "in": "path", "name": "domain", "required": true, "type": "string", "x-example": "openai.com"}, {"default": "hot", "description": "Sort: hot, new, top, or rising", "enum": ["hot", "new", "top", "rising"], "in": "query", "name": "sort", "type": "string"}, {"description": "Time window for top sort: hour, day, week, month, year, or all", "enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"description": "Maximum posts, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/domain/{domain}/posts", "pathParams": ["domain"], "produces": ["application/json"], "queryParams": [{"enum": ["hot", "new", "top", "rising"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-leads": {"id": "reddit-leads", "method": "GET", "params": [{"description": "What you offer, in plain language", "in": "query", "name": "q", "required": true, "type": "string", "x-example": "crm for small teams"}, {"description": "Restrict the search to a subreddit name, without r/", "in": "query", "name": "subreddit", "type": "string"}, {"default": "relevance", "description": "Sort: relevance, hot, new, top, or comments", "enum": ["relevance", "hot", "new", "top", "comments"], "in": "query", "name": "sort", "type": "string"}, {"default": "month", "description": "Time window: hour, day, week, month, year, or all", "enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"description": "Maximum leads returned, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Minimum buying-intent score to return, 0-10, defaults to 4", "in": "query", "name": "min_score", "type": "integer"}, {"default": "auto", "description": "Classifier: auto uses the model when configured, heuristic skips it, llm requires it", "enum": ["auto", "heuristic", "llm"], "in": "query", "name": "classifier", "type": "string"}], "path": "/reddit/leads", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "q", "required": true, "type": "string"}, {"in": "query", "name": "subreddit", "type": "string"}, {"enum": ["relevance", "hot", "new", "top", "comments"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "min_score", "type": "integer"}, {"enum": ["auto", "heuristic", "llm"], "in": "query", "name": "classifier", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-post": {"id": "reddit-post", "method": "GET", "params": [{"description": "Reddit post id or t3_ id", "in": "path", "name": "id", "required": true, "type": "string", "x-example": "1v8hy3q"}, {"default": false, "description": "Include public engagement metrics; costs 3 credits instead of 1", "in": "query", "name": "include_metrics", "type": "boolean"}], "path": "/reddit/post/{id}", "pathParams": ["id"], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "include_metrics", "type": "boolean"}], "security": ["ApiKeyAuth"]}, "reddit-search": {"id": "reddit-search", "method": "GET", "params": [{"description": "Search keywords", "in": "query", "name": "q", "required": true, "type": "string", "x-example": "gpt"}, {"description": "Restrict search to a subreddit name, without r/", "in": "query", "name": "subreddit", "type": "string"}, {"default": "relevance", "description": "Sort: relevance, hot, new, top, or comments", "enum": ["relevance", "hot", "new", "top", "comments"], "in": "query", "name": "sort", "type": "string"}, {"description": "Time window for top/comments sorts: hour, day, week, month, year, or all", "enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"description": "Maximum posts, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/search", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "q", "required": true, "type": "string"}, {"in": "query", "name": "subreddit", "type": "string"}, {"enum": ["relevance", "hot", "new", "top", "comments"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-subreddit-about": {"id": "reddit-subreddit-about", "method": "GET", "params": [{"description": "Subreddit name, without r/", "in": "path", "name": "subreddit", "required": true, "type": "string", "x-example": "OpenAI"}, {"description": "Maximum sample posts inspected, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}], "path": "/reddit/subreddit/{subreddit}/about", "pathParams": ["subreddit"], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "reddit-subreddit-comments": {"id": "reddit-subreddit-comments", "method": "GET", "params": [{"description": "Subreddit name, without r/", "in": "path", "name": "subreddit", "required": true, "type": "string", "x-example": "OpenAI"}, {"description": "Maximum comments, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/subreddit/{subreddit}/comments", "pathParams": ["subreddit"], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-subreddit-posts": {"id": "reddit-subreddit-posts", "method": "GET", "params": [{"description": "Subreddit name, without r/", "in": "path", "name": "subreddit", "required": true, "type": "string", "x-example": "OpenAI"}, {"default": "hot", "description": "Sort: hot, new, top, or rising", "enum": ["hot", "new", "top", "rising"], "in": "query", "name": "sort", "type": "string"}, {"description": "Time window for top sort: hour, day, week, month, year, or all", "enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"description": "Maximum posts, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/subreddit/{subreddit}/posts", "pathParams": ["subreddit"], "produces": ["application/json"], "queryParams": [{"enum": ["hot", "new", "top", "rising"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-subreddits-posts": {"id": "reddit-subreddits-posts", "method": "GET", "params": [{"description": "Comma-separated subreddit names, without r/, maximum 10", "in": "query", "name": "subreddits", "required": true, "type": "string", "x-example": "OpenAI,MachineLearning"}, {"default": "hot", "description": "Sort: hot, new, top, or rising", "enum": ["hot", "new", "top", "rising"], "in": "query", "name": "sort", "type": "string"}, {"description": "Time window for top sort: hour, day, week, month, year, or all", "enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"description": "Maximum posts, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/subreddits/posts", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "subreddits", "required": true, "type": "string"}, {"enum": ["hot", "new", "top", "rising"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-trends": {"id": "reddit-trends", "method": "GET", "params": [{"default": "hot", "description": "Sort: hot, new, rising, or top", "enum": ["hot", "new", "rising", "top"], "in": "query", "name": "sort", "type": "string"}, {"description": "Time window for top sort: hour, day, week, month, year, or all", "enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"description": "Maximum posts, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/trends", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["hot", "new", "rising", "top"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-user-comments": {"id": "reddit-user-comments", "method": "GET", "params": [{"description": "Public Reddit username, without u/", "in": "path", "name": "username", "required": true, "type": "string", "x-example": "reddit"}, {"description": "Maximum comments, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/user/{username}/comments", "pathParams": ["username"], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-user-posts": {"id": "reddit-user-posts", "method": "GET", "params": [{"description": "Public Reddit username, without u/", "in": "path", "name": "username", "required": true, "type": "string", "x-example": "reddit"}, {"description": "Maximum posts, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/user/{username}/posts", "pathParams": ["username"], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}}
22
+ {"reddit-comments": {"bodyParam": null, "bodyRequired": false, "id": "reddit-comments", "method": "GET", "params": [{"description": "Reddit post id or t3_ id", "in": "path", "name": "id", "required": true, "type": "string", "x-example": "1tka90t"}, {"default": "confidence", "description": "Comment order: confidence, top, new, controversial, old, or qa. Applied to the anonymous HTML request when metrics are enabled.", "enum": ["confidence", "top", "new", "controversial", "old", "qa"], "in": "query", "name": "sort", "type": "string"}, {"description": "Maximum comments returned, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"default": 3, "description": "Maximum flat comment depth returned in metrics mode.", "in": "query", "name": "depth", "type": "integer"}, {"default": false, "description": "Include public post and per-comment engagement metrics; costs 3 credits instead of 1", "in": "query", "name": "include_metrics", "type": "boolean"}], "path": "/reddit/comments/{id}", "pathParams": ["id"], "produces": ["application/json"], "queryParams": [{"enum": ["confidence", "top", "new", "controversial", "old", "qa"], "in": "query", "name": "sort", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "depth", "type": "integer"}, {"in": "query", "name": "include_metrics", "type": "boolean"}], "security": ["ApiKeyAuth"]}, "reddit-domain-posts": {"bodyParam": null, "bodyRequired": false, "id": "reddit-domain-posts", "method": "GET", "params": [{"description": "Domain hostname, without scheme or path", "in": "path", "name": "domain", "required": true, "type": "string", "x-example": "openai.com"}, {"default": "hot", "description": "Sort: hot, new, top, or rising", "enum": ["hot", "new", "top", "rising"], "in": "query", "name": "sort", "type": "string"}, {"description": "Time window for top sort: hour, day, week, month, year, or all", "enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"description": "Maximum posts, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/domain/{domain}/posts", "pathParams": ["domain"], "produces": ["application/json"], "queryParams": [{"enum": ["hot", "new", "top", "rising"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-leads": {"bodyParam": null, "bodyRequired": false, "id": "reddit-leads", "method": "GET", "params": [{"description": "What you offer, in plain language", "in": "query", "name": "q", "required": true, "type": "string", "x-example": "crm for small teams"}, {"description": "Restrict the search to a subreddit name, without r/", "in": "query", "name": "subreddit", "type": "string"}, {"default": "relevance", "description": "Sort: relevance, hot, new, top, or comments", "enum": ["relevance", "hot", "new", "top", "comments"], "in": "query", "name": "sort", "type": "string"}, {"default": "month", "description": "Time window: hour, day, week, month, year, or all", "enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"description": "Maximum leads returned, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Minimum buying-intent score to return, 0-10, defaults to 4", "in": "query", "name": "min_score", "type": "integer"}, {"default": "auto", "description": "Classifier: auto uses the model when configured, heuristic skips it, llm requires it", "enum": ["auto", "heuristic", "llm"], "in": "query", "name": "classifier", "type": "string"}], "path": "/reddit/leads", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "q", "required": true, "type": "string"}, {"in": "query", "name": "subreddit", "type": "string"}, {"enum": ["relevance", "hot", "new", "top", "comments"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "min_score", "type": "integer"}, {"enum": ["auto", "heuristic", "llm"], "in": "query", "name": "classifier", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-post": {"bodyParam": null, "bodyRequired": false, "id": "reddit-post", "method": "GET", "params": [{"description": "Reddit post id or t3_ id", "in": "path", "name": "id", "required": true, "type": "string", "x-example": "1v8hy3q"}, {"default": false, "description": "Include public engagement metrics; costs 3 credits instead of 1", "in": "query", "name": "include_metrics", "type": "boolean"}], "path": "/reddit/post/{id}", "pathParams": ["id"], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "include_metrics", "type": "boolean"}], "security": ["ApiKeyAuth"]}, "reddit-search": {"bodyParam": null, "bodyRequired": false, "id": "reddit-search", "method": "GET", "params": [{"description": "Search keywords", "in": "query", "name": "q", "required": true, "type": "string", "x-example": "gpt"}, {"description": "Restrict search to a subreddit name, without r/", "in": "query", "name": "subreddit", "type": "string"}, {"default": "relevance", "description": "Sort: relevance, hot, new, top, or comments", "enum": ["relevance", "hot", "new", "top", "comments"], "in": "query", "name": "sort", "type": "string"}, {"description": "Time window for top/comments sorts: hour, day, week, month, year, or all", "enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"description": "Maximum posts, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/search", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "q", "required": true, "type": "string"}, {"in": "query", "name": "subreddit", "type": "string"}, {"enum": ["relevance", "hot", "new", "top", "comments"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-subreddit-about": {"bodyParam": null, "bodyRequired": false, "id": "reddit-subreddit-about", "method": "GET", "params": [{"description": "Subreddit name, without r/", "in": "path", "name": "subreddit", "required": true, "type": "string", "x-example": "OpenAI"}, {"description": "Maximum sample posts inspected, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}], "path": "/reddit/subreddit/{subreddit}/about", "pathParams": ["subreddit"], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "reddit-subreddit-comments": {"bodyParam": null, "bodyRequired": false, "id": "reddit-subreddit-comments", "method": "GET", "params": [{"description": "Subreddit name, without r/", "in": "path", "name": "subreddit", "required": true, "type": "string", "x-example": "OpenAI"}, {"description": "Maximum comments, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/subreddit/{subreddit}/comments", "pathParams": ["subreddit"], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-subreddit-posts": {"bodyParam": null, "bodyRequired": false, "id": "reddit-subreddit-posts", "method": "GET", "params": [{"description": "Subreddit name, without r/", "in": "path", "name": "subreddit", "required": true, "type": "string", "x-example": "OpenAI"}, {"default": "hot", "description": "Sort: hot, new, top, or rising", "enum": ["hot", "new", "top", "rising"], "in": "query", "name": "sort", "type": "string"}, {"description": "Time window for top sort: hour, day, week, month, year, or all", "enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"description": "Maximum posts, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/subreddit/{subreddit}/posts", "pathParams": ["subreddit"], "produces": ["application/json"], "queryParams": [{"enum": ["hot", "new", "top", "rising"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-subreddits-posts": {"bodyParam": null, "bodyRequired": false, "id": "reddit-subreddits-posts", "method": "GET", "params": [{"description": "Comma-separated subreddit names, without r/, maximum 10", "in": "query", "name": "subreddits", "required": true, "type": "string", "x-example": "OpenAI,MachineLearning"}, {"default": "hot", "description": "Sort: hot, new, top, or rising", "enum": ["hot", "new", "top", "rising"], "in": "query", "name": "sort", "type": "string"}, {"description": "Time window for top sort: hour, day, week, month, year, or all", "enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"description": "Maximum posts, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/subreddits/posts", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "subreddits", "required": true, "type": "string"}, {"enum": ["hot", "new", "top", "rising"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-trends": {"bodyParam": null, "bodyRequired": false, "id": "reddit-trends", "method": "GET", "params": [{"default": "hot", "description": "Sort: hot, new, rising, or top", "enum": ["hot", "new", "rising", "top"], "in": "query", "name": "sort", "type": "string"}, {"description": "Time window for top sort: hour, day, week, month, year, or all", "enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"description": "Maximum posts, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/trends", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["hot", "new", "rising", "top"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["hour", "day", "week", "month", "year", "all"], "in": "query", "name": "time", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-user-comments": {"bodyParam": null, "bodyRequired": false, "id": "reddit-user-comments", "method": "GET", "params": [{"description": "Public Reddit username, without u/", "in": "path", "name": "username", "required": true, "type": "string", "x-example": "reddit"}, {"description": "Maximum comments, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/user/{username}/comments", "pathParams": ["username"], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "reddit-user-posts": {"bodyParam": null, "bodyRequired": false, "id": "reddit-user-posts", "method": "GET", "params": [{"description": "Public Reddit username, without u/", "in": "path", "name": "username", "required": true, "type": "string", "x-example": "reddit"}, {"description": "Maximum posts, defaults to 25 and clamps to 100", "in": "query", "name": "limit", "type": "integer"}, {"description": "Reddit pagination token", "in": "query", "name": "after", "type": "string"}], "path": "/reddit/user/{username}/posts", "pathParams": ["username"], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}}
23
23
  JSON
24
24
  OPERATION_IDS = JSON.parse(<<~'JSON').freeze
25
25
  ["reddit-comments", "reddit-domain-posts", "reddit-leads", "reddit-post", "reddit-search", "reddit-subreddit-about", "reddit-subreddit-comments", "reddit-subreddit-posts", "reddit-subreddits-posts", "reddit-trends", "reddit-user-comments", "reddit-user-posts"]
@@ -29,7 +29,7 @@ module Crawlora
29
29
  class Client
30
30
  attr_reader :base_url
31
31
 
32
- def initialize(api_key: ENV["CRAWLORA_API_KEY"], base_url: "https://api.crawlora.net/api/v1", timeout: 30, user_agent: "crawlora-reddit-ruby/0.1.1", transport: nil)
32
+ def initialize(api_key: ENV["CRAWLORA_API_KEY"], base_url: "https://api.crawlora.net/api/v1", timeout: 30, user_agent: "crawlora-reddit-ruby/0.1.2", transport: nil)
33
33
  @api_key = api_key
34
34
  @base_url = base_url.to_s.sub(%r{/+$}, "")
35
35
  @timeout = Float(timeout)
@@ -45,15 +45,24 @@ module Crawlora
45
45
  raise Errors::ClientError.new("unknown operation: #{operation_id}", operation_id: operation_id) unless operation
46
46
  raise Errors::ClientError.new("Crawlora API key is required", operation_id: operation_id) if @api_key.nil? || @api_key.to_s.empty?
47
47
  normalized = params.each_with_object({}) { |(key, value), out| out[key.to_s] = value }
48
+ payload = request_body(operation, normalized)
48
49
  url = build_url(operation, normalized)
49
50
  uri = URI.parse(url)
50
- request = Net::HTTP::Get.new(uri)
51
+ request = operation["method"] == "POST" ? Net::HTTP::Post.new(uri) : Net::HTTP::Get.new(uri)
52
+ unless payload.nil?
53
+ request.body = payload
54
+ request["Content-Type"] = "application/json"
55
+ end
51
56
  request["x-api-key"] = @api_key
52
57
  request["User-Agent"] = @user_agent
53
58
  request["Accept"] = operation["produces"].include?("text/plain") ? "application/json, text/plain" : "application/json"
54
59
  begin
55
60
  if @transport
56
- response = @transport.call(url, request.to_hash, @timeout)
61
+ response = if operation["method"] == "POST"
62
+ @transport.call(url, request.to_hash, @timeout, "POST", payload)
63
+ else
64
+ @transport.call(url, request.to_hash, @timeout)
65
+ end
57
66
  status = Integer(response.fetch(:status) { response.fetch("status") })
58
67
  body = response.fetch(:body) { response.fetch("body", "") }
59
68
  headers = response.fetch(:headers) { response.fetch("headers", {}) }
@@ -156,8 +165,21 @@ module Crawlora
156
165
 
157
166
  private
158
167
 
168
+ # POST operations take their JSON body under the body parameter name or "body".
169
+ def request_body(operation, params)
170
+ name = operation["bodyParam"]
171
+ return nil if name.nil?
172
+ value = params.key?(name) ? params[name] : params["body"]
173
+ if value.nil?
174
+ raise Errors::ClientError.new("missing request body: #{name}", operation_id: operation["id"]) if operation["bodyRequired"]
175
+ return nil
176
+ end
177
+ value.is_a?(String) ? value : JSON.generate(value)
178
+ end
179
+
159
180
  def build_url(operation, params)
160
181
  known = operation["params"].map { |param| param["name"] }
182
+ known << "body" if operation["bodyParam"]
161
183
  unknown = params.keys - known
162
184
  raise Errors::ClientError.new("unknown parameters: #{unknown.join(', ')}", operation_id: operation["id"]) unless unknown.empty?
163
185
  path = operation["path"].dup
@@ -1,5 +1,5 @@
1
1
  module Crawlora
2
2
  module Reddit
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,16 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crawlora-reddit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Crawlora
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-09 00:00:00.000000000 Z
11
+ date: 2026-10-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Credential-free Reddit API access through Crawlora's hosted service.
13
+ description: Ruby client for Crawlora's hosted Reddit API. Covers search, post and
14
+ comment details, subreddit feeds, user history, domain listings, trends, and leads
15
+ across 12 endpoints.
14
16
  email:
15
17
  executables: []
16
18
  extensions: []
@@ -47,5 +49,5 @@ requirements: []
47
49
  rubygems_version: 3.4.19
48
50
  signing_key:
49
51
  specification_version: 4
50
- summary: Reddit client for the Crawlora hosted API
52
+ summary: Reddit API client for Crawlora (12 endpoints)
51
53
  test_files: []