SlyFawkes / ruby_ergast_api_client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

swagger_client

SwaggerClient - the Ruby gem for the Ergast F1 DB OpenAPI Spec

This is a partial definition of the Ergast F1 API in the OpenAPI 3.0 specification. Of the the endpoints that are implemented here, the url paths and return data schemas are structured to match the structure currently used on the live Ergast API. You should be able to use the as a starting point for generating your client libraries for use with Ergast, or setting up your own API to use with a copy of the Ergast DB. Some notes: - This only defines the JSON data schema, not the XML version of the API return data - Outside of the year, most of the inline parameters used by the Ergast API are not defined here. - The placeholder values for year are not currently implemented.

This SDK is automatically generated by the Swagger Codegen project:

  • API version: 1.1.0
  • Package version: 1.0.0
  • Build package: io.swagger.codegen.v3.generators.ruby.RubyClientCodegen For more information, please visit http://github.com/adampax

Installation

Build a gem

To build the Ruby code into a gem:

gem build swagger_client.gemspec

Then either install the gem locally:

gem install ./swagger_client-1.0.0.gem

(for development, run gem install --dev ./swagger_client-1.0.0.gem to install the development dependencies)

or publish the gem to a gem hosting service, e.g. RubyGems.

Finally add this to the Gemfile:

gem 'swagger_client', '~> 1.0.0'

Install from Git

If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:

gem 'swagger_client', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'

Include the Ruby code directly

Include the Ruby code directly using -I as follows:

ruby -Ilib script.rb

Getting Started

Please follow the installation procedure and then run the following code:

# Load the gem
require 'swagger_client'

api_instance = SwaggerClient::ConstructorsApi.new
year = '2020' # String | Year in question
opts = { 
  offset: 56, # Integer | The number of items to skip before starting to collect the result set.
  limit: 30 # Integer | The numbers of items to return.
}

begin
  result = api_instance.get_constructor_standings_by_year(year, opts)
  p result
rescue SwaggerClient::ApiError => e
  puts "Exception when calling ConstructorsApi->get_constructor_standings_by_year: #{e}"
end

api_instance = SwaggerClient::ConstructorsApi.new
year = '2020' # String | Year in question
opts = { 
  offset: 56, # Integer | The number of items to skip before starting to collect the result set.
  limit: 30 # Integer | The numbers of items to return.
}

begin
  result = api_instance.get_constructors_by_year(year, opts)
  p result
rescue SwaggerClient::ApiError => e
  puts "Exception when calling ConstructorsApi->get_constructors_by_year: #{e}"
end

api_instance = SwaggerClient::DriversApi.new
year = '2020' # String | Year in question
opts = { 
  offset: 56, # Integer | The number of items to skip before starting to collect the result set.
  limit: 30 # Integer | The numbers of items to return.
}

begin
  result = api_instance.get_driver_standings_by_year(year, opts)
  p result
rescue SwaggerClient::ApiError => e
  puts "Exception when calling DriversApi->get_driver_standings_by_year: #{e}"
end

api_instance = SwaggerClient::ResultsApi.new
year = '2020' # String | Year in question
opts = { 
  offset: 56, # Integer | The number of items to skip before starting to collect the result set.
  limit: 30 # Integer | The numbers of items to return.
}

begin
  result = api_instance.get_results_by_year(year, opts)
  p result
rescue SwaggerClient::ApiError => e
  puts "Exception when calling ResultsApi->get_results_by_year: #{e}"
end

api_instance = SwaggerClient::ResultsApi.new
year = '2020' # String | Year in question
constructor_id = 'constructor_id_example' # String | Limit results to this constructor
opts = { 
  offset: 56, # Integer | The number of items to skip before starting to collect the result set.
  limit: 30 # Integer | The numbers of items to return.
}

begin
  result = api_instance.get_results_by_year_and_constructor(year, constructor_id, opts)
  p result
rescue SwaggerClient::ApiError => e
  puts "Exception when calling ResultsApi->get_results_by_year_and_constructor: #{e}"
end

api_instance = SwaggerClient::ResultsApi.new
year = '2020' # String | Year in question
round = 'round_example' # String | Round in question
opts = { 
  offset: 56, # Integer | The number of items to skip before starting to collect the result set.
  limit: 30 # Integer | The numbers of items to return.
}

begin
  result = api_instance.get_results_by_year_and_round(year, round, opts)
  p result
rescue SwaggerClient::ApiError => e
  puts "Exception when calling ResultsApi->get_results_by_year_and_round: #{e}"
end

api_instance = SwaggerClient::ScheduleApi.new
year = '2020' # String | Year in question
opts = { 
  offset: 56, # Integer | The number of items to skip before starting to collect the result set.
  limit: 30 # Integer | The numbers of items to return.
}

begin
  result = api_instance.get_season_by_year(year, opts)
  p result
rescue SwaggerClient::ApiError => e
  puts "Exception when calling ScheduleApi->get_season_by_year: #{e}"
end

Documentation for API Endpoints

All URIs are relative to https://ergast.com/api/f1

Class Method HTTP request Description
SwaggerClient::ConstructorsApi get_constructor_standings_by_year GET /{year}/constructorStandings.json
SwaggerClient::ConstructorsApi get_constructors_by_year GET /{year}/constructors.json
SwaggerClient::DriversApi get_driver_standings_by_year GET /{year}/driverStandings.json
SwaggerClient::ResultsApi get_results_by_year GET /{year}/results.json
SwaggerClient::ResultsApi get_results_by_year_and_constructor GET /{year}/constructors/{constructorId}/results.json
SwaggerClient::ResultsApi get_results_by_year_and_round GET /{year}/{round}/results.json
SwaggerClient::ScheduleApi get_season_by_year GET /{year}.json

Documentation for Models

Documentation for Authorization

All endpoints do not require authorization.

About


Languages

Language:Ruby 99.5%Language:Shell 0.5%