# Setup Guide - API Keys and Authentication
URL: https://sportsgameodds.com/docs/basics/setup

Setup Guide - API Keys and Authentication [#setup-guide---api-keys-and-authentication]

There are only 2 things you need to get started - an API key and a way to make requests.

API Key [#api-key]

* **[Get an API key here](/pricing)**. An API key is required to make requests and retrieve data from the API.
* **We offer an eternally free plan**. Simply select the "Amateur" plan. During checkout, it may require you to add a credit card but it will never be charged unless you later decide to upgrade.
* **Your key will be sent to your email address**. If you haven't received your API key within a couple of minutes of checking out, please check your spam folder. If it isn't there either, please reach out to support at [support@sportsgameodds.com](mailto:support@sportsgameodds.com) and we'll re-generate it for you.
* **Keep your API key secret**. Never expose it publicly. Your API key is your password to the API.
* **Include your API key in all requests**. It can be added in either the `x-api-key` header or the `apiKey` query param.

Making Requests Manually [#making-requests-manually]

Reference Docs Tool [#reference-docs-tool]

You can make requests directly from our [API Reference](/docs/reference) page:

1. Navigate to [sportsgameodds.com/docs/reference](/docs/reference).
2. Enter your API key in the **Token** field under **API KEY** (Either ApiKeyHeader or ApiKeyParam should be selected).
3. Select an endpoint from the left sidebar (Events, Teams, Sports, etc.).
4. Click **Test Request** to open the interactive request panel.
5. Use the **Query** (or **Query Parameters**) section to set request parameters
6. Click **Send** to execute the request.
7. The response will be displayed in the **Response** section under **Body**.

<Callout type="info">
  The reference docs page can also give you additional ready-to-use code snippets in multiple languages
</Callout>

Postman [#postman]

Postman is a popular tool for testing APIs. We provide an official collection you can import.

1. **Install Postman**: [postman.com/downloads](https://www.postman.com/downloads/) and install it.
2. **Download our collection**: <a href="/SportsGameOdds_Postman_Collection.json" download="SportsGameOdds_Postman_Collection.json">SportsGameOdds Postman Collection</a>
3. **Import the collection**: In Postman, click `Import`, then drag select the file you just downloaded.
4. **Set your API key**: Ensure `SportsGameOdds API` is selected → Go to the `Variables` tab → replace `YOUR_API_KEY_HERE` with your actual API key → click `Save`.
5. **Make a request**: Expand the `Events` folder → click `Get Events` → Adjust parameters (ex: set `oddsAvailable` to `true`) → click `Send`

Directly in the Browser [#directly-in-the-browser]

You can make requests directly in your browser's address bar using the apiKey parameter to authenticate. Simply visit a URL like this:

```
https://api.sportsgameodds.com/v2/sports/?apiKey=YOUR_API_KEY&leagueID=NBA,NFL,MLB&oddsAvailable=true&limit=3
```

You can add or remove query parameters to adjust the data you receive. For example to only get moneylines, add `&oddIDs=points-home-game-ml-home,points-away-game-ml-away`to the end of the URL.

<Callout type="warn">
  API responses can be large and may slow/crash your browser tab. This method is great for quick/simple tests but not recommended for regular usage.
</Callout>

Making Requests In Code [#making-requests-in-code]

With HTTP Libraries [#with-http-libraries]

Replace `YOUR_API_KEY` with your actual API key in the examples below:

<Tabs items={['Javascript', 'Python', 'Ruby', 'PHP', 'Java']}>
  <Tab value="Javascript">
    ```js
    // This example uses fetch() but you can use any HTTP library
    fetch("https://api.sportsgameodds.com/v2/sports/", {// [!code focus]
      method: "GET", // [!code focus]
      headers: { "X-Api-Key": "YOUR_API_KEY" }, // [!code focus]
    }) // [!code focus]
      .then((response) => response.json())
      .then((data) => console.log(data))
      .catch((error) => console.error(error));
    ```
  </Tab>

  <Tab value="Python">
    ```python
    # This example uses the requests library
    import requests
    headers = {
        'X-Api-Key': 'YOUR_API_KEY'
    }
    url = 'https://api.sportsgameodds.com/v2/sports/' # [!code focus]
    response = requests.get(url, headers=headers) # [!code focus]
    print(response.json())
    ```
  </Tab>

  <Tab value="Ruby">
    ```ruby
    # This example uses the net/http library
    require 'net/http'
    require 'json'

    uri = URI('https://api.sportsgameodds.com/v2/sports/')
    request = Net::HTTP::Get.new(uri)
    request['X-Api-Key'] = 'YOUR_API_KEY'

    response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
      http.request(request)
    end

    parsed_response = JSON.parse(response.body)
    puts parsed_response
    ```
  </Tab>

  <Tab value="PHP">
    ```php
    // This example uses cURL
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, 'https://api.sportsgameodds.com/v2/sports/');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-Api-Key: YOUR_API_KEY']);

    $response = curl_exec($ch);
    curl_close($ch);

    echo $response;
    ```
  </Tab>

  <Tab value="Java">
    ```java
    // This example uses HttpURLConnection
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.net.HttpURLConnection;
    import java.net.URL;

    public class Main {
        public static void main(String[] args) {
            try {
                URL url = new URL("https://api.sportsgameodds.com/v2/sports/");
                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                conn.setRequestMethod("GET");
                conn.setRequestProperty("X-Api-Key", "YOUR_API_KEY");

                BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                String inputLine;
                StringBuffer content = new StringBuffer();
                while ((inputLine = in.readLine()) != null) {
                    content.append(inputLine);
                }

                in.close();
                conn.disconnect();
                System.out.println(content.toString());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    ```
  </Tab>
</Tabs>

With Our SDK [#with-our-sdk]

First, install the SDK:

<Tabs items={['JavaScript (TypeScript)', 'Python', 'Ruby', 'Go', 'Java']}>
  <Tab value="JavaScript (TypeScript)">
    ```bash
    npm install sports-odds-api # [!code focus]
    yarn add sports-odds-api # if you're using yarn
    pnpm add sports-odds-api # if you're using pnpm
    ```
  </Tab>

  <Tab value="Python">
    ```bash
    pip install sports-odds-api
    ```
  </Tab>

  <Tab value="Ruby">
    ```bash
    gem install sports-odds-api
    ```
  </Tab>

  <Tab value="Go">
    ```bash
    go get github.com/SportsGameOdds/sports-odds-api-go
    ```
  </Tab>

  <Tab value="Java">
    ```groovy
    // Maven (pom.xml)
    <dependency>
      <groupId>com.sportsgameodds.api</groupId>
      <artifactId>sports-odds-api</artifactId>
      <version>1.0.0</version>
    </dependency>

    // Gradle (build.gradle)
    implementation 'com.sportsgameodds.api:sports-odds-api:1.0.0'
    ```
  </Tab>
</Tabs>

Then, make a request. Simply replace `YOUR_API_KEY` with your actual API key in the examples below:

<Tabs items={['TypeScript', 'Python', 'Ruby', 'Go', 'Java']}>
  <Tab value="TypeScript">
    ```js
    import SportsGameOdds from "sports-odds-api";

    const client = new SportsGameOdds({
      apiKeyHeader: "YOUR_API_KEY",
    });

    const sports = await client.sports.get(); // [!code focus]
    console.log(sports.data); // [!code focus]
    ```
  </Tab>

  <Tab value="Python">
    ```python
    from sports_odds_api import SportsGameOdds

    client = SportsGameOdds(
        api_key_param='YOUR_API_KEY'
    )

    # Fetch sports data
    sports = client.sports.get() # [!code focus]
    print(sports.data) # [!code focus]
    ```
  </Tab>

  <Tab value="Ruby">
    ```ruby
    require "sports_odds_api"

    client = SportsOddsAPI::Client.new(
      api_key_param: 'YOUR_API_KEY'
    )

    # Fetch sports data
    sports = client.sports.get # [!code focus]
    puts sports.data # [!code focus]
    ```
  </Tab>

  <Tab value="Go">
    ```go
    package main

    import (
    	"context"
    	"fmt"
    	sportsoddsapi "github.com/SportsGameOdds/sports-odds-api-go"
    	"github.com/SportsGameOdds/sports-odds-api-go/option"
    )

    func main() {
    	client := sportsoddsapi.NewClient(
    		option.WithAPIKeyParam("YOUR_API_KEY"),
    	)

    	// Fetch sports data
    	ctx := context.Background() // [!code focus]
    	sports, _ := client.Sports.Get(ctx) // [!code focus]
    	fmt.Println(sports.Data) // [!code focus]
    }
    ```
  </Tab>

  <Tab value="Java">
    ```java
    import com.sportsgameodds.api.client.SportsGameOddsClient;
    import com.sportsgameodds.api.client.okhttp.SportsGameOddsOkHttpClient;

    public class Main {
        public static void main(String[] args) {
            SportsGameOddsClient client = SportsGameOddsOkHttpClient.builder()
                .apiKeyHeader("YOUR_API_KEY")
                .build();

            // Fetch sports data
            var sports = client.sports().get(); // [!code focus]
            System.out.println(sports.items()); // [!code focus]
        }
    }
    ```
  </Tab>
</Tabs>

<Callout type="info" title="Learn More About the SDK">
  Check out our [SDK Guide](/v2/sdk) for comprehensive documentation including pagination, error handling, filtering, and advanced features.
</Callout>