Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

120
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda