# Setup Guide - API Keys and Authentication
URL: https://sockodds.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](https://sockodds.com/signup/).** An API key is required to make requests.
- **We offer an eternally free plan.** The Lite key covers AFL and NRL from 3 bookmakers at 10 requests a minute, no card.
- **Your key is shown once.** Only a hash is stored on our side, so a lost key cannot be recovered — mint a new one.
- **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.** 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 the [API Reference](https://sockodds.com/docs/reference/):

1. Open an endpoint page (Events, Teams, Sports, …).
2. Paste your key into the **API key** field.
3. Fill in query parameters.
4. Click **Send**. The response appears below with its status, timing and rate-limit headers.

> The reference pages also give you ready-to-use code snippets in multiple languages.

### Postman [#postman]

1. **Install Postman**: [postman.com/downloads](https://www.postman.com/downloads/).
2. **Download our collection**: [SockOdds Postman Collection](https://sockodds.com/SockOdds_Postman_Collection.json).
3. **Import the collection**: click Import and drop the file in.
4. **Set your API key**: select `SockOdds API` → Variables → replace `YOUR_API_KEY_HERE` → Save.
5. **Make a request**: expand Events → Get Events → set `oddsAvailable` to true → Send.

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

Use the `apiKey` parameter to authenticate in the address bar:

```
https://api.sockodds.com/v2/sports/?apiKey=YOUR_API_KEY
```

Add or remove query parameters to adjust what you receive. To get only head-to-head prices on the events endpoint add `&oddID=points-home-game-ml-home,points-away-game-ml-away`.

> API responses can be large and may slow your browser tab. Great for quick tests, not recommended for regular use.

## Making requests in code [#making-requests-in-code]

### With HTTP libraries [#with-http-libraries]

Replace `YOUR_API_KEY` with your actual API key:

**Browser URL** · **cURL** · **JavaScript** · **Python** · **Ruby** · **PHP** · **Java** · **Go**

```text
https://api.sockodds.com/v2/sports/?apiKey=YOUR_API_KEY
```

```bash
curl -X GET "https://api.sockodds.com/v2/sports/?" -H "x-api-key: YOUR_API_KEY"
```

```javascript
const response = await fetch("https://api.sockodds.com/v2/sports/?", { headers: { "x-api-key": "YOUR_API_KEY" } });
const { data, nextCursor, notice } = await response.json();
console.log(JSON.stringify(data, null, 2));
```

```python
import requests

response = requests.get("https://api.sockodds.com/v2/sports/", params=dict(), headers={"x-api-key": "YOUR_API_KEY"})
output = response.json()
print(output["data"])
```

```ruby
require 'net/http'
require 'json'

uri = URI("https://api.sockodds.com/v2/sports/?")
req = Net::HTTP::Get.new(uri)
req['x-api-key'] = 'YOUR_API_KEY'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
puts JSON.pretty_generate(JSON.parse(res.body)['data'])
```

```php
<?php
$ch = curl_init("https://api.sockodds.com/v2/sports/?");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['x-api-key: YOUR_API_KEY']);
$output = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($output['data']);
```

```java
import java.net.URI;
import java.net.http.*;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.sockodds.com/v2/sports/?"))
    .header("x-api-key", "YOUR_API_KEY").GET().build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

```go
req, _ := http.NewRequest("GET", "https://api.sockodds.com/v2/sports/?", nil)
req.Header.Set("x-api-key", "YOUR_API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil { log.Fatal(err) }
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
```

### With the SDK [#with-the-sdk]

The official SportsGameOdds SDKs are generated from the same v2 schema SockOdds serves, so they work here unchanged — set the base URL. First, install:

**JavaScript (TypeScript)** · **Python** · **Ruby** · **Go** · **Java**

```bash
npm install sports-odds-api   # or yarn add / pnpm add
```

```bash
pip install sports-odds-api
```

```bash
gem install sports-odds-api
```

```bash
go get github.com/SportsGameOdds/sports-odds-api-go
```

```groovy
// Gradle
implementation 'com.sportsgameodds.api:sports-odds-api:1.0.0'
```

Then make a request:

**TypeScript** · **Python** · **Ruby** · **Go** · **Java**

```typescript
import SportsGameOdds from "sports-odds-api";

const client = new SportsGameOdds({ apiKeyHeader: "YOUR_API_KEY", baseURL: "https://api.sockodds.com/v2" });
const res = await client.sports.get();
console.log(res.data);
```

```python
from sports_odds_api import SportsGameOdds

client = SportsGameOdds(api_key_header="YOUR_API_KEY", base_url="https://api.sockodds.com/v2")
res = client.sports.get()
print(res.data)
```

```ruby
require "sports_odds_api"

client = SportsOddsAPI::Client.new(api_key_header: "YOUR_API_KEY", base_url: "https://api.sockodds.com/v2")
res = client.sports.get
puts res.data
```

```go
client := sportsoddsapi.NewClient(option.WithAPIKeyHeader("YOUR_API_KEY"), option.WithBaseURL("https://api.sockodds.com/v2"))
res, err := client.Sports.Get(context.Background())
if err != nil { log.Fatal(err) }
fmt.Println(res.Data)
```

```java
SportsGameOddsClient client = SportsGameOddsOkHttpClient.builder()
    .apiKeyHeader("YOUR_API_KEY").baseUrl("https://api.sockodds.com/v2").build();
var res = client.sports().get();
System.out.println(res.items());
```

> Learn more about the SDKSee the [SDK guide](https://sockodds.com/docs/sdk/) for pagination, error handling, filtering and advanced features.

> Need help?[FAQ](https://sockodds.com/docs/faq/) · [Email](mailto:api@sockodds.com) · [Contact](https://sockodds.com/contact-us/)
