---
id: error-handling
title: Sport Line API — Error Handling
description: Instructions for recognizing, handling, and diagnosing Sport Line API access, parameter, and response errors.
version: v1
language: en
---

# Sport Line API — Error Handling

## Common Error Format

Most access and parameter validation errors use the following format:

```json
{
  "error_code": 100,
  "error_message": "Invalid Package"
}
```

| Field | Type | Description |
|---|---|---|
| `error_code` | number | Numeric error category code |
| `error_message` | string | Text describing the cause |

When processing a response, check for `error_code` and `error_message`. Do not rely only
on the HTTP response status.

## 1. API Key Errors

### `Missing Package header`

The API key was not sent in the `Package` HTTP header.

```json
{
  "error_code": 100,
  "error_message": "Missing Package header"
}
```

Check whether:

- the `Package` header is present;
- the key was mistakenly added to the URL or request body;
- the HTTP client adds the header to every request.

### `Invalid Package`

The supplied key was not found in the system.

Check whether:

- the entire key was copied;
- there are spaces before or after the value;
- the key belongs to the correct environment;
- the key was replaced by the SportAPI manager.

### `Package has expired`

The key has expired or access has been disabled.

What to do:

- confirm the access expiration date;
- check the payment or trial status;
- contact the SportAPI manager to renew or activate access.

## 2. Subscription and Permission Errors

### `Access denied`

The key does not provide access to the requested data or sport.

Check whether:

- `sportId` is included in the client's subscription;
- the correct API method is being used;
- an internal method is being requested;
- the key belongs to the selected connection.

### `The language is not available in your package.`

The requested language exists in Sport Line API but is not included in the client's
subscription.

What to do:

- use a language available to the current key;
- request the language list from the manager;
- add another language to the subscription if necessary.

## 3. Request Parameter Errors

### `Invalid language`

The supplied language code is not supported by the API.

Check:

- the `lang` value in the URL;
- the spelling and letter case of the language code;
- that the request path contains no extra characters.

### `Wrong data type (accept only live or line)`

The line type parameter contains a value other than `live` or `line`.

```json
{
  "error_code": 90,
  "error_message": "Wrong data type (accept only live or line)"
}
```

Allowed values:

| Value | Purpose |
|---|---|
| `line` | Prematch matches |
| `live` | Matches currently in progress |

The `search` method explicitly returns this error. For other methods, an invalid line
type may result in an empty response, so validate the value before sending the request.

## 4. Responses from the Specific Match Method

Some `event` method states are not returned as `error_code`. Instead, they appear as a
message inside a successful response envelope.

### `Game not found`

No match was found for the supplied identifier.

```json
{
  "status": 1,
  "page": "/v1/event",
  "body": {
    "message": "Game not found"
  }
}
```

Check whether:

- `game_id` or `sgame_id` is correct;
- the match belongs to the requested `line` or `live` type;
- the match exists in the current `events` response.

### `Game id finished`

The match is no longer available in the current line under the supplied `game_id`.

```json
{
  "status": 1,
  "page": "/v1/event",
  "body": {
    "message": "Game id finished"
  }
}
```

The message does not identify the exact reason. The Prematch match may have moved to
Live under a new `game_id`, been cancelled, or disappeared from the line for another
reason. Sport Line API does not provide separate statuses for these cases.

What to do:

- stop requesting `event` with the previous `game_id`;
- refresh the match list through `events` for the required line type;
- do not conclude that the match started, ended, or was cancelled based only on this
  message.

## 5. An Empty Response Is Not Always an Error

An empty `body` array may mean that no data is available for the selected conditions:

```json
{
  "status": 1,
  "page": "/v1/events",
  "body": []
}
```

Before showing an error to the user, check whether:

- matches are available for the selected sport;
- `tournamentId` is correct;
- the request uses the correct `line` or `live` type;
- the requested data is available to the current subscription.

## Recommended Application Handling

1. Parse the JSON response.
2. Check for `error_code`.
3. If `error_code` is present, handle the known value and write technical information
   to the log without the API key.
4. If the response contains `body.message`, handle the state of the specific match.
5. If `body` is an empty array, display an empty state instead of a system error.
6. Do not expose the API key, internal URL, or complete technical log to clients.

## Information to Send to Support

If the cause of an error is unknown, send:

- the request URL without the API key;
- the request time and time zone;
- `error_code` and `error_message`;
- the response body with all sensitive data removed;
- the `line` or `live` type;
- the language, `sportId`, `tournamentId`, and `gameId`, if used.

Do not send an active API key in a public chat or issue.

- SportAPI support: [@suport_sportapi](https://t.me/suport_sportapi)
- Official website: [sportapi.net](https://sportapi.net)
