Gitbook
dailyjournal.gitbook.io › solutions › hackerrank-solutions › certify › rest-api-intermediate
Rest API (Intermediate) | HackerRank | Solutions
To access a competition, perform an HTTP GET request to https://jsonmock.hackerrank.com/api/football_competitions?name=<name>&year=<year> where <name> is the name of the competition and <year> is the year of the competition.
GitHub
github.com › runitrupam › Hackerrank-Rest-API-Intermediate-Skills-Certification-Test › blob › main › REST API ____Football Competition Winner's Goals.py
Hackerrank-Rest-API-Intermediate-Skills-Certification-Test/REST API ____Football Competition Winner's Goals.py at main · runitrupam/Hackerrank-Rest-API-Intermediate-Skills-Certification-Test
... Complete the function getWinnerTotalGoals in the editor below. ... The function must return an integer denoting the total number of goals scored in all matches in the given competition by the team who won the competition.
Author runitrupam
GitHub
github.com › devreena03 › hackerrank-restapi-java › blob › main › football-matches.md
hackerrank-restapi-java/football-matches.md at main · devreena03/hackerrank-restapi-java
] } https://jsonmock.hackerrank.com/api/football_matches?year=2011&team2=Barcelona&page=1 { "page": 1, "per_page": 10, "total": 6, "total_pages": 1, "data": [ { "competition": "UEFA Champions League", "year": 2011, "round": "GroupH", "team1": "BATE Borisov", "team2": "Barcelona", "team1goals": "0", "team2goals": "5" }, { "competition": "UEFA Champions League", "year": 2011, "round": "GroupH", "team1": "Viktoria Plzen", "team2": "Barcelona", "team1goals": "0", "team2goals": "4" }, ...
Author devreena03
GitHub
github.com › Harika-BV › React-API-Intermediate-Hackerrank › blob › master › (REST API) Football Competition winner's goals.py
React-API-Intermediate-Hackerrank/(REST API) Football Competition winner's goals.py at master · Harika-BV/React-API-Intermediate-Hackerrank
def getWinnerTotalGoals(competition, year):
· count = 0
· #Getting Winner
· winnerUrl = "https://jsonmock.hackerrank.com/api/football_competitions?name="+competition+"&year="+str(year)
· winnerReq = requests.get(winnerUrl)
· winnerData = json.loads(winnerReq.text)
·
Author Harika-BV
GitHub
github.com › runitrupam › Hackerrank-Rest-API-Intermediate-Skills-Certification-Test › blob › main › demo run of Football Competition Winner's Goals
Hackerrank-Rest-API-Intermediate-Skills-Certification-Test/demo run of Football Competition Winner's Goals at main · runitrupam/Hackerrank-Rest-API-Intermediate-Skills-Certification-Test
url = ("https://jsonmock.hackerrank.com/api/football_matches?competition={}&year={}&team{}={}&page={}". format(competition,str(year),team_no,winner_team,1)) response1 = requests.get(url).json() #REST API: Football Competition Winner's Goals · def home_team(year,winner_team,team_no): params1 = {'year': str(year), 'team'+str(team_no): winner_team, 'page': 1, 'competition': competition ·
Author runitrupam
GitHub
github.com › ejaj › rest-api-intermediate › blob › main › football_competition_winner's_goals_hackerrank.py
rest-api-intermediate/football_competition_winner's_goals_hackerrank.py at main · ejaj/rest-api-intermediate
competition_winner_team = competition_request['data'][0]['winner'] ... url = 'https://jsonmock.hackerrank.com/api/football_matches?competition='+str(competition_name)+'&year='+str(year)+'&team1='+str(competition_winner_team)+'&page=1'
Author ejaj
GitHub
github.com › khalil-Elf441 › REST-API-Total-Goals-by-a-Team
GitHub - khalil-Elf441/REST-API-Total-Goals-by-a-Team: REST API: Total Goals by a Team · GitHub
Your task is to get the total number of goals scored by a given team in a given year. To access a collection of matches, perform GET requests to · https://jsonmock.hackerrank.com/api/football_matches?year=<year>&team1=<team>&page=<page>
Starred by 4 users
Forked by 6 users
Languages Python
GitHub
github.com › TarasAntoniuk › hackerrank-prep-rest-api
GitHub - TarasAntoniuk/hackerrank-prep-rest-api: HackerRank problem solving for REST API certification · GitHub
Implement a REST service that takes a competition name and a year as input, and returns the total number of goals scored by the winning team across all matches of that competition during the specified year.
Author TarasAntoniuk
GitHub
github.com › 3RB16 › Rest-API-Intermediate-hackerrank-solution › blob › main › getWinnerTotalGoals.py
Rest-API-Intermediate-hackerrank-solution/getWinnerTotalGoals.py at main · 3RB16/Rest-API-Intermediate-hackerrank-solution
'competition': compeition
· ... data
·
· def handleData(team, whichTeam,compeition):
· teamNum = 'team' + str(whichTeam) + 'goals'
·...
Author 3RB16
Ride With the Sun
valsze.de › home › rest api: football competition winner’s goals
REST API: Football Competition Winner's Goals
September 14, 2023 - { "name":"English Premier League", "country":"England", "year":2014, "winner":"Chelsea", "runnerup":"Manchester City" } Next, to access a collection of matches played by a given team in a given competition and year, perform GET requests to · https://jsonmock.hackerrank.com/api/football_matches?competition=<competition>&year=<year>&team1=<team>&page=<page>
GitHub
github.com › sumantopal07 › Rest-API-Intermediate-Hackerrank-Test
GitHub - sumantopal07/Rest-API-Intermediate-Hackerrank-Test · GitHub
Solution : Only done with (1+10+10) GET requests by taking advantage of the constraint of maximum of 10 goals scored by any team. 1 for finding the winner 10 for summing the goals for home matches 10 for summing the goals for away mathces · ...
Starred by 36 users
Forked by 8 users
Studocu
studocu.com › jadavpur university › information and coding theory › rest api timed assessment challenge: team goals & draw analysis
REST API Timed Assessment Challenge: Team Goals & Draw Analysis - Studocu
September 7, 2024 - url = 'jsonmock.hackerrank/api/football_matches?competition=' +competition+ '&year=' +str(year)+ '&team2=' +winner+ '&page=1' response = requests('GET', url, headers={}, data={}) r = json(response.text('utf8')) r {'page': '1', 'per_page': 10, 'total': 6, 'total_pages': 1, 'data': [{'competition': 'UEFA Champions League', 'year': 2011, 'round': 'GroupE', 'team1': 'Valencia CF', 'team2': 'Chelsea', 'team1goals': '1', 'team2goals': '1'}, {'competition': 'UEFA Champions League', 'year': 2011, 'round': 'GroupE', 'team1': 'KRC Genk', 'team2': 'Chelsea', 'team1goals': '1', 'team2goals': '1'}, {'compe
GitHub
gist.github.com › e050802a345cde62c1a6ba675bd8ccfe
Football Score, Competition Winner - Hackerrank · GitHub
Football Score, Competition Winner - Hackerrank · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters ·
YouTube
youtube.com › watch
Hackerrank Certification REST APIs Certification (Football matches APIs) #hackerrank - YouTube
This Video is a part of playlist "Crack javascript Interviews"https://www.youtube.com/watch?v=ET3IiPLI-JI&list=PLIGDNOJWiL18kcjnrT0KT64bo-kOYyQUF&ab_channel=...
Published May 16, 2023
GitHub
github.com › saajithmohd › Hacker-Rank-REST-API
GitHub - saajithmohd/Hacker-Rank-REST-API: n this challenge, the REST API contains information about football matches. The provided API allows querying matches by teams and year. Your task is to get the total number of goals scored by a given team in a given year. To access a collection of matches, perform GET requests to https://jsonmock.hackerrank.com/api/football_matches?year=&team1=&page= https://jsonmock.hackerrank.com/api/football_matches?year=&team2=&page= where is the year of the competition, is the
n this challenge, the REST API contains information about football matches. The provided API allows querying matches by teams and year. Your task is to get the total number of goals scored by a given team in a given year.
Author saajithmohd
Top answer 1 of 3
2
If the API allows these many calls, you can use a multiprocessing.pool.Pool function and iterate through each page parallelly to reduce time. This should work:
Copyimport requests
from functools import partial
from multiprocessing.pool import Pool
def loop(page,year,r,per_page):
r = requests.get('https://jsonmock.hackerrank.com/api/football_matches?year='+str(year)+'&page='+str(page)).json()
try:
for i in range(0, per_page):
if int(r['data'][i]['team1goals']) == int(r['data'][i]['team2goals']):
increase = 1
else:
increase = 0
except:
increase = 0
return increase
if __name__ == "__main__":
year = 2011
draw = []
r = requests.get('https://jsonmock.hackerrank.com/api/football_matches?year='+str(year)+'&page=1').json()
total_pages = r['total_pages']
per_page = r['per_page']
pages = range(1, total_pages+1)
pool = Pool()
f = pool.map(partial(loop,year=year,r=r,per_page=per_page),pages)
draw += f
final = 0
for x in draw:
x = int(x)
final += x
print(final) #516
2 of 3
2
You should use multithreading and make multiple requests in parallel.
YouTube
youtube.com › watch
REST API Intermediate Certification #03 - YouTube
HackerRank All skills certifications Github Link https://github.com/tkssharma/hackerrank-full-stack/tree/master/Full Stack Certifications- https://github...
Published December 13, 2021