Skip to content

Conversation

@bougyman
Copy link
Member

@bougyman bougyman commented Jan 5, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 5, 2026 12:35
@bougyman bougyman merged commit d29aa7d into main Jan 5, 2026
6 checks passed
@bougyman bougyman deleted the add-search-endpoints branch January 5, 2026 12:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds search endpoint functionality to the Kalshi API client, introducing two new search methods for retrieving tags by categories and filters by sports.

Key Changes:

  • Introduces a new Search::Client with two endpoint methods: tags_by_categories and filters_by_sports
  • Creates a new ApiClient base class for API client implementations
  • Adds corresponding endpoint classes SeriesTags and SportsFilters that extend Kalshi::Endpoint

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
lib/kalshi/api_client.rb Adds new base class for API client implementations with shared initialization pattern
lib/kalshi/client.rb Adds search method that returns a memoized Search::Client instance
lib/kalshi/search/client.rb Implements Search API client with methods for tags and filters endpoints
lib/kalshi/search/series_tags.rb Endpoint class for fetching tags by categories
lib/kalshi/search/sports_filters.rb Endpoint class for fetching filters by sports
test/kalshi/client_test.rb Adds test verifying search method returns correct instance type
test/kalshi/search/client_test.rb Adds integration tests for tags_by_categories and filters_by_sports methods
Readme.adoc Documents the new search endpoints with usage examples
Gemfile.lock Updates version from 0.0.1 to 0.0.2

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
Copy link

Copilot AI Jan 5, 2026

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 filters_by_sports (plural) but the documentation shows filters_by_sport (singular). Update the documentation to match the implementation.

Suggested change
==== 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

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +35
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
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing memoization test for the search method. Following the existing pattern established for the market method in this file and the Market::Client tests, you should add a test to verify that multiple calls to client.search return the same instance using assert_same.

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +19
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
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test coverage for memoization behavior. Following the pattern in test/kalshi/market/client_test.rb, you should add tests to verify that SeriesTags instances are memoized when tags_by_categories is called multiple times. This ensures consistent behavior across API client implementations.

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +30
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
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test coverage for memoization behavior. Following the pattern in test/kalshi/market/client_test.rb, you should add tests to verify that SportsFilters instances are memoized when filters_by_sports is called multiple times. This ensures consistent behavior across API client implementations.

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +14
SeriesTags.new(client).all
end

def filters_by_sports
SportsFilters.new(client).all
end
Copy link

Copilot AI Jan 5, 2026

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +13
SeriesTags.new(client).all
end

def filters_by_sports
SportsFilters.new(client).all
Copy link

Copilot AI Jan 5, 2026

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 SportsFilters 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.

Suggested change
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 uses AI. Check for mistakes.
Comment on lines +1 to +12
# frozen_string_literal: true

module Rubyists
module Kalshi
# API Client Base Class
class ApiClient
attr_reader :client

def initialize(client)
@client = client
end
end
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new ApiClient base class duplicates the exact pattern from Market::Client (attr_reader :client and initialize method). Consider having Market::Client inherit from ApiClient to avoid duplication and maintain consistency across API client implementations.

Copilot uses AI. Check for mistakes.

[source,ruby]
----
tags = client.search.tags_by_category
Copy link

Copilot AI Jan 5, 2026

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 shows tags_by_category (singular). Update the documentation to match the implementation.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants