Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

121
Vistas
Where do I put an authenticated API request in Ruby on Rails?

I am building a sports app as a side project to help learn Ruby on Rails and about API's, but after a lot of searching around, I haven't found any clear instructions on where (or what) I am supposed to paste the API request in Rails.

The sample link for the API I want to use looks like this..

https://soccer.sportmonks.com/api/v2.0/leagues?api_token={API_TOKEN}
"data": [
          {
            "id": 271,
            "active": true,
            "type": "domestic",
            "legacy_id": 43,
            "country_id": 320,
            "logo_path": "https://cdn.sportmonks.com/images/soccer/leagues/271.png",
            "name": "Superliga",
            "is_cup": false,
            "current_season_id": 17328,
            "current_round_id": 199450,
            "current_stage_id": 77447994,
            "live_standings": true,
            "coverage": {
                "predictions": true,
                "topscorer_goals": true,
                "topscorer_assists": true,
                "topscorer_cards": true
            }
          }
        ]

I understand a lot of what I'm looking at there, the need for the API token, and how it can be customized, but I'm confused as to where in my Rails files this would be posted? In the HTML structure? In the Javascript folder? How do I take this from the source API website and put it on mine?

I've been looking around for a while but all I see are instructions on how to build your own API, not use someone else's on your webpage.

Any resources or help would be greatly appreciated. I love the idea of the flexibility of API's from a theoretical perspective and look forward to working with them, I just need to figure out where or what I should be looking to cut/paste.

Edit: here is an example github of what it's supposed to look like, but I still don't see where I actually input the exact location of the link. https://github.com/vnnoder/sportmonks-ruby

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could install their gem, so you don't need to worry about requests syntax.

For the API token, you could put in an initializer, so the sportmonks API is initialized.

initializers/sportmonks.rb

Sportmonks.configure do |config|
  # PS: it's not ideal to put your raw API key here for security purposes. 
  # You should use environment variables for production projects.
  # For testing purposes it is fine.
  config.api_token = "your API KEY here"
end

So now, when you start your rails server, then the gem is going to be usable.

To test the gem, you can start a rails console and you can simply do

Sportmonks.leagues

And you will have a list of all the leagues.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda