Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
8Gates
Contributor II
Contributor II

Rest API Data Connection

HI - I am trying to create a REST API Data connection to a Football Prediction website

The rest code generated below works in a test harness outside of Qlik.

But I am unsure of how to set up the data connection and what goes where to connect.

Rest Data ConnectionRest Data Connection

package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://football-prediction-api.p.rapidapi.com/api/v2/predictions?iso_date=2018-12-01&market=classic&federation=UEFA"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("x-rapidapi-host", "football-prediction-api.p.rapidapi.com")
	req.Header.Add("x-rapidapi-key", "xxxxxxxxxx32b4f9ap13e9c5jsn5e425aec9f10")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
Labels (1)
1 Solution

Accepted Solutions
8Gates
Contributor II
Contributor II
Author

Solved for those interested - this set pulls back all Leagues from the API for the UK as an example

Needed to add a header section to the API connection

connect.png

 

LIB CONNECT TO 'REST_httpsapi-football-v1.p.rapidapi.comv2leaguescountry{country_name}{season}';

RestConnectorMasterTable:
SQL SELECT
"__KEY_api",
(SELECT
"league_id",
"name",
"type",
"country",
"country_code",
"season",
"season_start",
"season_end",
"logo",
"flag",
"standings" AS "standings_u0",
"is_current",
"__KEY_leagues",
"__FK_leagues",
(SELECT
"standings",
"players",
"topScorers",
"predictions",
"odds",
"__KEY_coverage",
"__FK_coverage",
(SELECT
"events",
"lineups",
"statistics",
"players_statistics",
"__FK_fixtures"
FROM "fixtures" FK "__FK_fixtures")
FROM "coverage" PK "__KEY_coverage" FK "__FK_coverage")
FROM "leagues" PK "__KEY_leagues" FK "__FK_leagues")
FROM JSON (wrap off) "api" PK "__KEY_api";

[fixtures]:
LOAD [events],
[lineups],
[statistics],
[players_statistics],
[__FK_fixtures] AS [__KEY_coverage]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_fixtures]);


[coverage]:
LOAD [standings],
[players],
[topScorers],
[predictions],
[odds],
[__KEY_coverage],
[__FK_coverage] AS [__KEY_leagues]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_coverage]);


[leagues]:
LOAD [league_id],
[name],
[type],
[country],
[country_code],
[season],
[season_start],
[season_end],
[logo],
[flag],
[standings_u0] AS [standings_u0],
[is_current],
[__KEY_leagues],
[__FK_leagues] AS [__KEY_api]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_leagues]);


[api]:
LOAD [__KEY_api]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY_api]);


DROP TABLE RestConnectorMasterTable;

View solution in original post

2 Replies
8Gates
Contributor II
Contributor II
Author

Solved for those interested - this set pulls back all Leagues from the API for the UK as an example

Needed to add a header section to the API connection

connect.png

 

LIB CONNECT TO 'REST_httpsapi-football-v1.p.rapidapi.comv2leaguescountry{country_name}{season}';

RestConnectorMasterTable:
SQL SELECT
"__KEY_api",
(SELECT
"league_id",
"name",
"type",
"country",
"country_code",
"season",
"season_start",
"season_end",
"logo",
"flag",
"standings" AS "standings_u0",
"is_current",
"__KEY_leagues",
"__FK_leagues",
(SELECT
"standings",
"players",
"topScorers",
"predictions",
"odds",
"__KEY_coverage",
"__FK_coverage",
(SELECT
"events",
"lineups",
"statistics",
"players_statistics",
"__FK_fixtures"
FROM "fixtures" FK "__FK_fixtures")
FROM "coverage" PK "__KEY_coverage" FK "__FK_coverage")
FROM "leagues" PK "__KEY_leagues" FK "__FK_leagues")
FROM JSON (wrap off) "api" PK "__KEY_api";

[fixtures]:
LOAD [events],
[lineups],
[statistics],
[players_statistics],
[__FK_fixtures] AS [__KEY_coverage]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_fixtures]);


[coverage]:
LOAD [standings],
[players],
[topScorers],
[predictions],
[odds],
[__KEY_coverage],
[__FK_coverage] AS [__KEY_leagues]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_coverage]);


[leagues]:
LOAD [league_id],
[name],
[type],
[country],
[country_code],
[season],
[season_start],
[season_end],
[logo],
[flag],
[standings_u0] AS [standings_u0],
[is_current],
[__KEY_leagues],
[__FK_leagues] AS [__KEY_api]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_leagues]);


[api]:
LOAD [__KEY_api]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY_api]);


DROP TABLE RestConnectorMasterTable;

Natet78
Contributor
Contributor

Hi

I'm having the same problem with the REST API Data connection to the API-Football

I can't connect to the server. Can you publish a screenshot over your settings in the connection?

Thanks in advance!

Br

Fredrik