-
Notifications
You must be signed in to change notification settings - Fork 0
feat: adds search endpoints #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -156,6 +156,32 @@ candlesticks = client.market.candlesticks.batch( | |||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| === Search | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Access Search endpoints via the `search` namespace. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ==== Tags by Category | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| https://docs.kalshi.com/api-reference/search/get-tags-for-series-categories[API Reference] | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Get tags organized by series categories: | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| [source,ruby] | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| tags = client.search.tags_by_category | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ==== Filters by Sport | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| https://docs.kalshi.com/api-reference/search/get-filters-for-sports[API Reference] | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Get filters organized by sport: | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| [source,ruby] | ||||||||||||||||||||||||||||||||||||||
| ---- | ||||||||||||||||||||||||||||||||||||||
| filters = client.search.filters_by_sport | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+174
to
+182
|
||||||||||||||||||||||||||||||||||||||
| ==== Filters by Sport | |
| https://docs.kalshi.com/api-reference/search/get-filters-for-sports[API Reference] | |
| Get filters organized by sport: | |
| [source,ruby] | |
| ---- | |
| filters = client.search.filters_by_sport | |
| ==== Filters by Sports | |
| https://docs.kalshi.com/api-reference/search/get-filters-for-sports[API Reference] | |
| Get filters organized by sports: | |
| [source,ruby] | |
| ---- | |
| filters = client.search.filters_by_sports |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Rubyists | ||
| module Kalshi | ||
| # API Client Base Class | ||
| class ApiClient | ||
| attr_reader :client | ||
|
|
||
| def initialize(client) | ||
| @client = client | ||
| end | ||
| end | ||
|
Comment on lines
+1
to
+12
|
||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| # frozen_string_literal: true | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| module Rubyists | ||||||||||||||||||||||||||||||||||||||||||||||
| module Kalshi | ||||||||||||||||||||||||||||||||||||||||||||||
| module Search | ||||||||||||||||||||||||||||||||||||||||||||||
| # Search API Client | ||||||||||||||||||||||||||||||||||||||||||||||
| class Client < ApiClient | ||||||||||||||||||||||||||||||||||||||||||||||
| def tags_by_categories | ||||||||||||||||||||||||||||||||||||||||||||||
| SeriesTags.new(client).all | ||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def filters_by_sports | ||||||||||||||||||||||||||||||||||||||||||||||
| SportsFilters.new(client).all | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+9
to
+13
|
||||||||||||||||||||||||||||||||||||||||||||||
| SeriesTags.new(client).all | |
| end | |
| def filters_by_sports | |
| SportsFilters.new(client).all | |
| @series_tags ||= SeriesTags.new(client) | |
| @series_tags.all | |
| end | |
| def filters_by_sports | |
| @sports_filters ||= SportsFilters.new(client) | |
| @sports_filters.all |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding memoization for the SeriesTags instance to match the pattern used in Market::Client. The endpoint classes should be instantiated once and reused, similar to how series_list, markets, and other endpoints are memoized with ||= in the Market::Client implementation.
| SeriesTags.new(client).all | |
| end | |
| def filters_by_sports | |
| SportsFilters.new(client).all | |
| end | |
| series_tags.all | |
| end | |
| def filters_by_sports | |
| sports_filters.all | |
| end | |
| private | |
| def series_tags | |
| @series_tags ||= SeriesTags.new(client) | |
| end | |
| def sports_filters | |
| @sports_filters ||= SportsFilters.new(client) | |
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Rubyists | ||
| module Kalshi | ||
| module Search | ||
| # Series Tags API endpoint | ||
| class SeriesTags < Kalshi::Endpoint | ||
| def all | ||
| client.get('search/tags_by_categories') | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Rubyists | ||
| module Kalshi | ||
| module Search | ||
| # Sports Filters API endpoint | ||
| class SportsFilters < Kalshi::Endpoint | ||
| def all | ||
| client.get('search/filters_by_sports') | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,14 @@ | |
| assert_instance_of Rubyists::Kalshi::Market::Client, client.market | ||
| end | ||
| end | ||
|
|
||
| describe '#search' do | ||
| it 'returns a Search::Client instance' do | ||
| client = Rubyists::Kalshi::Client.new | ||
|
|
||
| assert_instance_of Rubyists::Kalshi::Search::Client, client.search | ||
| end | ||
| end | ||
|
Comment on lines
+29
to
+35
|
||
| end | ||
|
|
||
| describe Rubyists::Kalshi do | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative '../../helper' | ||
|
|
||
| describe Rubyists::Kalshi::Search::Client do | ||
| let(:client) { Rubyists::Kalshi::Client.new } | ||
| let(:search_client) { client.search } | ||
| let(:base_url) { Rubyists::Kalshi.config.base_url } | ||
|
|
||
| describe '#tags_by_categories' do | ||
| it 'fetches tags by categories' do | ||
| stub_request(:get, "#{base_url}/search/tags_by_categories") | ||
| .to_return(status: 200, body: '{"tags_by_categories": {}}', headers: { 'Content-Type' => 'application/json' }) | ||
|
|
||
| response = search_client.tags_by_categories | ||
|
|
||
| assert_equal({ tags_by_categories: {} }, response) | ||
| end | ||
| end | ||
|
Comment on lines
+10
to
+19
|
||
|
|
||
| describe '#filters_by_sports' do | ||
| it 'fetches filters by sports' do | ||
| stub_request(:get, "#{base_url}/search/filters_by_sports") | ||
| .to_return(status: 200, body: '{"filters_by_sports": {}}', headers: { 'Content-Type' => 'application/json' }) | ||
|
|
||
| response = search_client.filters_by_sports | ||
|
|
||
| assert_equal({ filters_by_sports: {} }, response) | ||
| end | ||
| end | ||
|
Comment on lines
+21
to
+30
|
||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method name in the documentation doesn't match the actual implementation. The code implements
tags_by_categories(plural) but the documentation showstags_by_category(singular). Update the documentation to match the implementation.