0% found this document useful (0 votes)
20 views

API Code

The document contains code for two API requests to retrieve cricket match data from the Cricbuzz API. The first part defines a function to get a list of matches using a specific series ID, while the second part retrieves live score data for a match based on its ID. Both sections include the necessary API URL, headers, and functions to parse the JSON response.

Uploaded by

rudraksheez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

API Code

The document contains code for two API requests to retrieve cricket match data from the Cricbuzz API. The first part defines a function to get a list of matches using a specific series ID, while the second part retrieves live score data for a match based on its ID. Both sections include the necessary API URL, headers, and functions to parse the JSON response.

Uploaded by

rudraksheez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Matches List API Code:

let
// Define the API URL and headers
apiUrl = "https://cricbuzz-cricket.p.rapidapi.com/series/v1/7607",
headers = [
#"X-RapidAPI-Key" = "Paste your API Key ",
#"X-RapidAPI-Host" = "cricbuzz-cricket.p.rapidapi.com"
],
// Create a function to make the API request
getApiData = (url as text, headers as record) =>
let
// Make the request
response = Web.Contents(url, [Headers=headers]),
// Parse the JSON response
jsonResponse = Json.Document(response)
in
jsonResponse,
// Call the function to get the API data
apiData = getApiData(apiUrl, headers)
in
apiData
Live Score API Code :
let
// Define the API URL and headers

MatchID = Text.From(Live_Match_ID{0}[MatchID]),
// Make sure Live_MatchID is your table name and MatchID is your ID Column
name
LastRul="scard",
apiUrl = "https://cricbuzz-cricket.p.rapidapi.com/mcenter/v1/"& MatchID
&"/"&LastRul,
headers = [
#"X-RapidAPI-Key" = "Paste your key",
#"X-RapidAPI-Host" = "cricbuzz-cricket.p.rapidapi.com"
],
// Create a function to make the API request
getApiData = (url as text, headers as record) =>
let
// Make the request
response = Web.Contents(url, [Headers=headers]),
// Parse the JSON response
jsonResponse = Json.Document(response)
in
jsonResponse,
// Call the function to get the API data
apiData = getApiData(apiUrl, headers)
in
apiData

You might also like