Giter Club home page Giter Club logo

world_cup_json's Introduction

FIFA WORLD CUP 2022

and we made it! 2024 WWC or 2026 MWC in US/Canada/Mexico is anyone's game :D Congrats to Argentina!

--

We are super up and running for 2022. Note URL change! Please remember to make a PR with your nice apps, raspberry pi projects, etc. And my favorite part of this whole thing, the students who get super excited about coding something.

Update: Have finally hit 10k RPM for 2022 as well!

PROJECTS USING THIS API IN 2022

(Feel free to submit a PR with your project!)

todo:

  • scrape match statistics

fixed:

  • issue with hanging/overloaded workers for scraping
  • match start detection

Setup: usual rails setup then Setup2022.setup_teams Setup2022.setup_groups AllMatchesService.setup

And if you have 64 matches you are good to go! From there on out you can call jobs directly or use the app/jobs/scheduler.rb to update them. If you want to run the scraping tasks automatically, you'll need another tab open and run ENABLE_CRON=true bundle exec good_jobs start

https://worldcupjson.net

Main response endpoint: https://worldcupjson.net/matches/today

DETAILED EXAMPLE RESPONSE

detailed_response

** note if match statistics make it in, they are all ints - but I have to find them!

(note, the full matches endpoint has up to a 5 minutes cache on it and does not return all events - if you want real time updates please use /matches/today, /matches/id, or /matches/current)

ABOUT

This is a simple backend for a scraper that grabs current world cup results and outputs them as JSON. UPDATE 8 Jun 2015 - This is now working for the Women's World Cup. UPDATE 14 June 2018 - Updated for the World Cup in 2018 with 7 hours to spare! Update 13 Oct 2022- Guess we'll do this again!

Special thanks to my former employer Software For Good for encouraging me to make this many years ago...

RATE LIMITING

The current rate limit is 10 requests every 60 seconds. This is open to change at anytime depending on load, but I'll always keep it so a few requests can fire off in parallel. Please keep your polling down to once a minute or so, 30 seconds if you are feeling greedy, you're not going to get updated information any quicker than that.

ENDPOINTS

(some of the teams endpoints were never used may be deprecated for 2022)

[url]/teams/ for a list of teams with group ID and FIFA code

[url]/matches/ for all matches (Example JSON object at the bottom of this README)

Note - if you want all matches with all details,you must now pass ?details=true to this endpoint. All details will be present by default for endpoints like matches/today that return less matches...

[url]/teams/ results for each team (wins, losses, points, goals_for, goals_away, games_played)

[url]/teams/USA see next match info, last match info, current standings, etc

OTHER ENDPOINTS

[url]/matches/today/
[url]/matches/tomorrow/
[url]/matches/current/

You can also retrieve the matches for any team if you know their FIFA code (get fifa code from teams endpoint) by passing it in as a param.

Example: [url]/matches/country?fifa_code=ISL

Other Params

  • You can append a start date or a start date and and end date to get the matches for those dates. Example /matches?start_date=2018-06-19&end_date=2018-06-21 Please use YYYY-MM-DD as your param. end_date is optional.

  • You can append ?callback=foo to get a JSONP response

    Example: https://worldcupjson.net/matches/today?callback=bar

  • You can append ?by_date=desc to any query to sort the matches by furthest in the future to furthest in the past. ?by_date=asc does past to future. (ASC is default sort with no params)

    Example:[url]/matches/today/?by_date=DESC

You can also use the by param to get some other sortings of the match list.

  • total_goals will sort matches with the largest number of total goals to the least

  • home_team_goals will sort matches with the largest number of home team goals to the least

  • away_team_goals will sort matches with the largest number of away team goals to the least

  • closest_scores will sort matches with draws first to largest winning margin

    Example:[url]/matches/current/?by=closest_scores

JSONP

JSONP old school The API also supports JSONP style output via the callback parameter, e.g. [url]/teams/results?callback=processData

The response includes the same data output as the regular GET call without parameters, but wrapped inside a function. This can be used to get around cross origin issues.

EXAMPLE RESPONSES

Detailed Match View

PROJECTS USING THIS API IN 2018

2018 projects submitted

PROJECTS USING THIS API IN 2014

Some 2014 projects submitted * http://alexb.ninja/wc * https://github.com/fatiherikli/worldcup (displays World Cup results in the terminal) * https://github.com/ColtCarder/XMPP-World-Cup-Bot (Ruby/Blather XMPP Bot to private message live World Cup events as well as overall results.) * https://github.com/gberger/hubot-world-cup-live (Hubot plugin that pushes World Cup goals to a chat room) * World Cup SMS updates at http://worldcupsms.herokuapp.com/ by @andyjiang * https://github.com/brenopolanski/chrome-worldcup2014-extension (World Cup 2014 - Chrome Extension) * http://worldcup2014.meteor.com/ - betting pool app for @q42 built by @primigenus using @meteor * https://github.com/Friss/WorldCup - World Cup matches with the arena in the background * https://github.com/sestaton/WorldCupStats - World Cup stats and match information at the command line
## BACKGROUND

You can read a blog post about building the API here: http://softwareforgood.com/soccer-good/

DONATIONS

Some people have asked if they can make donations. I'd love for you to donate some time writing code or docs or tests, but this is shared totally gratis. If you're interested in throwing some cash someone's way, why not help out organizations working wwith refugees or across borders. At this time of coming together as a human community, let's remember that arbitrary lines on a map still have the power to hurt people. Doctors Without Borders Aegean Boat Report

TRY IT OUT

https://worldcupjson.net/matches

https://worldcupjson.net/matches/today

https://worldcupjson.net/matches/current

https://worldcupjson.net/teams

https://worldcupjson.net/teams/USA

UPDATES

Updates June 19, 2018

  • New rate limit -- some of you are really hammering the server. You can now make 10 requests every 60 seconds, requests after that will return 429 with your reset time. Please try to limit polling to once every minute or so and if you are building a SPA please do some cacheing/storing on your side and don't send a request with every user interaction. If you need a whitelist for more requests, please let me know and we can do it, but right now fully half of the requests get throttled and it's a fair amount of load to deal with that many requests coming in more often than 10s apart.

  • Better cacheing/fixed broken JSONP cacheing

  • Scrapers almost finished being reworked

  • New param added to the matches endpoint. You can pass ?start_date=2018-06-21 or ?start_date=2018-06-19&end_date=2018-06-24

    (If you pass one date, you'll get matches for that day, otherwise for the range of days specified. Please use YYYY-MM-DD format even though it is weird for the rest of the world not to use YYYY-DD-MM)

Updates June 18, 2018

  • We now retrieve match statistics as well (attempts on goal, saves, etc). This will show up at all the matches endpoints. If you want a more truncated view of a match (no events or stats) please pass ?details=false to any match endpoint

  • You can now retrieve a match by fifa_id if you only want one specific match, just use /matches/fifa_id/300331499 or as a shortcut just /matches/300331499. You'll get a 404 error back if no match has that id.

  • Scrapers are being refactored to actually have readable methods, memoize parsed information, etc. Views not calculating anything should increase response time considerably, which is good as we are now at about 30-40 rps.

WARNING

Removing self deprecating warning. I wrote the best code I could 4 years ago and got it working for the whole Cup, and I'm making it better now. Don't apologize for code you write in a rush to build a cool thing! A bad habit! Just make it better if/when you can.

https://www.linkedin.com/pulse/world-cup-api-take-2-eric-stiens/

world_cup_json's People

Contributors

arghgr avatar bryant1410 avatar caseyhelbling avatar cedricblondeau avatar cengiz-io avatar dependabot[bot] avatar dg01d avatar eeddaann avatar eslley avatar estiens avatar friss avatar gk4m avatar matthewmcvickar avatar meisam-dodangeh avatar mikkelwf avatar mufratkarim avatar nicolopignatelli avatar pedsm avatar primigenus avatar pyro2927 avatar riceluxs1t avatar sazap10 avatar selfish avatar spapas avatar stephanmax avatar vitorfre avatar wilchen558 avatar wwahammy avatar yasincandev avatar zucchinize avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

world_cup_json's Issues

Status changes and events

  • Need to get status changes (completed, extra time, etc) working for 2018
  • Need to get live events working for 2018

DONE: real time score

Will be updated in time for 15 June 2018 matches, will post here when finished

Senegal group matches show "To Be Determined"

Group stage matches for Senegal are showing the country name "To Be Determined" instead of their name. This is possibly happening because Sen is lowercase in the team.json file?

{
  "group_id": 8,
  "code": "Sen",
  "name": "Senegal"
}

Add timestamp of last update

It would be nice to have a timestamp of the last update in the returned data, especially when a game is in progress.

include JSON Pretty Print

like this where $return is your data

if (phpversion('tidy') > 5.3) {
                echo json_encode($return, JSON_PRETTY_PRINT);
            }
            else {
                echo json_encode($return, 128);
        }

Time zone issues

We are now pulling in UTC times but still parsing them with the Time Zone of the stadium, need to use raw UTC across the app

Germany v France still listed as in progress

Match number 46 between Germany and France is still listed as in progress.

{
"match_number": 46,
"location": "Olympic Stadium",
"datetime": "2015-06-26T15:00:00.000-05:00",
"status": "in progress",
"home_team":{
"country": "Germany",
"code": "GER",
"goals": 1
},
"away_team":{
"country": "France",
"code": "FRA",
"goals": 1
},
"winner": null,
"winner_code": null,
"home_team_events":[{"id": 725, "type_of_event": "yellow-card", "player": "Mittag", "time": "37"...}],
"away_team_events":[{"id": 728, "type_of_event": "yellow-card", "player": "Delie", "time": "55"...}]
}

I think this may be related to #35.

teams/results not updating

hey,

Love the API and i'm sure you've got this in hand already, but are you looking to resolve the data not being updated in the teams/results endpoint?

{
"id": 1,
"country": "Russia",
"alternate_name": null,
"fifa_code": "RUS",
"group_id": 1,
"group_letter": "A",
"wins": 0, *
"draws": 0, *
"losses": 0, *
"games_played": 0, *
"points": 0, *
"goals_for": 0, *
"goals_against": 0, *
"goal_differential": 0 *
}

Result after 90 minutes

Hello, how can I get the result after basic time of match - I mean 90 minutes + additional time? Or just after the first half?

Add match number

Every game in the world cup seems to have a match number.
In former times this was an integer like "1", "2", ... "64".

This does not seem to be available any more. Instead - on fifa.com it seems that there is a Match number in the format "300331503" for the first game Russia vs Saudi Arabia.

Add these to /matches for identification

...
"match_number": "300331503",
...

Invalid json when there are no away_team_events

This json is invalid as "away_team_events" has nothing

{"match_number":23,"location":"Arena Corinthians","datetime":"2014-06-19T16:00:00.000-03:00","status":"in progress","home_team":{"country":"Uruguay","code":"URU","goals":0},"away_team":{"country":"England","code":"ENG","goals":0},"winner":null,"home_team_events":{"id":246,"type_of_event":"yellow-card","player":"D. Godin","time":"9"},"away_team_events":}

no sort by date

Hi, I use http://worldcup.sfg.io/matches
but now all the dates of the matches are messed up, the first in the json was a match
{"venue": "Saransk", "location": "Mordovia Arena", "status": "future", "time": null, "fifa_id": "300331550", "datetime": "2018-06-19T12 : 00: 00Z "...
but expected
{"venue": "Moscow", "location": "Luzhniki Stadium", "status": "completed", "time": "full-time", "fifa_id": "300331503", "datetime": "2018 -06-14T15: 00: 00Z "

New branch to look at

Did a little work tonight. We are SO close to having goals, cards, and substitutions for each match in real time. Things still needed

  1. Some work on the RABL output. Ideally home_team events are structured under home team and away_team_events by away_team. Not familiar with RABL so running into some syntax issues

  2. I have grabbed the event type and player, we also need to grab the time of the event if possible.

Please checkout the new_stats_scraper branch, pull to your local host, and feel free to work on it. You'll need to run the migrations, then run rake fifa:get_all_events

Group Results api now working

Cheers for your good work guys.
It seems like group_results API is not working, could you have a look over it?

Thanks in advance.

Substitution issues in MAR vs IRN

I've noticed that there's some issues in home_team_events and away_team_events where there are 4-5 substitution-in events, including some duplicates.

{
  "home_team_events": [
      {
        "id": 23,
        "type_of_event": "yellow-card",
        "player": "Karim EL AHMADI",
        "time": "34'"
      },
      {
        "id": 26,
        "type_of_event": "substitution-in",
        "player": "Sofyan AMRABAT",
        "time": "76'"
      },
      {
        "id": 27,
        "type_of_event": "substitution-in",
        "player": "Aziz BOUHADDOUZ",
        "time": "76'"
      },
      {
        "id": 31,
        "type_of_event": "substitution-in",
        "player": "Aziz BOUHADDOUZ",
        "time": "77'"
      },
      {
        "id": 30,
        "type_of_event": "substitution-in",
        "player": "Manuel DA COSTA",
        "time": "82'"
      }
    ],
    "away_team_events": [
      {
        "id": 22,
        "type_of_event": "yellow-card",
        "player": "Masoud SHOJAEI",
        "time": "10'"
      },
      {
        "id": 24,
        "type_of_event": "yellow-card",
        "player": "Alireza JAHANBAKHSH",
        "time": "47'"
      },
      {
        "id": 25,
        "type_of_event": "substitution-in",
        "player": "Mehdi TAREMI",
        "time": "68'"
      },
      {
        "id": 28,
        "type_of_event": "substitution-in",
        "player": "Pejman MONTAZERI",
        "time": "79'"
      },
      {
        "id": 29,
        "type_of_event": "substitution-in",
        "player": "Majid HOSSEINI",
        "time": "82'"
      },
      {
        "id": 32,
        "type_of_event": "substitution-in",
        "player": "Saman GHODDOS",
        "time": "85'"
      }
    ]
}

I've also noticed that there are no substitution-out events.

Some match times are wrong

I think some matches have the wrong datetime. For example the United States vs. Colombia game has a timestamp of "T17:00:00.000-05:00" or 6pm eastern time, but the game is at 8pm.

First match with TBD Teams has a different structure.

Hi, i've been using the API on my site, and I've noticed that the times I've used http://worldcup.sfg.io/matches as a data source, the first match with TBD teams is missing both home_team_tbd and away_team_tbd properties.

I hope the markdown code works. Best regards.

[{
    "match_number": 53,
    "location": "Estadio Nacional",
    "datetime": "2014-06-30T13:00:00.000-03:00",
    "status": "future",
    "home_team": ["home_team_tbd"],
    "away_team": ["away_team_tbd"],
    "winner": null,
    "home_team_events": "no events available for this match",
    "away_team_events": "no events available for this match"
}, {
    "match_number": 54,
    "location": "Estadio Beira-Rio",
    "datetime": "2014-06-30T17:00:00.000-03:00",
    "status": "future",
    "home_team_tbd": "[1G]",
    "away_team_tbd": "[2H]",
    "home_team": ["home_team_tbd"],
    "away_team": ["away_team_tbd"],
    "winner": null,
    "home_team_events": "no events available for this match",
    "away_team_events": "no events available for this match"
}, {
    "match_number": 55,
    "location": "Arena de Sao Paulo",
    "datetime": "2014-07-01T13:00:00.000-03:00",
    "status": "future",
    "home_team_tbd": "[1F]",
    "away_team_tbd": "[2E]",
    "home_team": ["home_team_tbd"],
    "away_team": ["away_team_tbd"],
    "winner": null,
    "home_team_events": "no events available for this match",
    "away_team_events": "no events available for this match"
}];

Add group/knockout information to matches

Please add information to /matches what type of game it is. For instance something like

...
"match_type": "group",
"match_type_ident": "B"
....

or

...
"match_type": "knockout",
"match_type_ident": "round_of_16"
....

or

...
"match_type": "knockout",
"match_type_ident": "quarter_final"
....

or

...
"match_type": "knockout",
"match_type_ident": "semi_final"
....

or

...
"match_type": "knockout",
"match_type_ident": "play_off_3"
....

or

...
"match_type": "knockout",
"match_type_ident": "final"
....

Add match events

Add events for the match:

  • injury-time (with information about how much injury time was added on)
  • half-time
  • full-time

Duplication of data

In the matches feed, http://worldcup.sfg.io/matches some events are duplicated.

Match 54 has several on various events, such as:

        {
            "id": 1227,
            "type_of_event": "substitution-out",
            "player": "Mustafi",
            "time": "70"
        },
        {
            "id": 1232,
            "type_of_event": "substitution-in",
            "player": "Khedira",
            "time": "70"
        },
        {
            "id": 1231,
            "type_of_event": "substitution-out",
            "player": "Mustafi",
            "time": "70"
        }

and

        {
            "id": 1246,
            "type_of_event": "goal",
            "player": "özil",
            "time": "120"
        },
        {
            "id": 1241,
            "type_of_event": "goal",
            "player": "özil",
            "time": "1202"
        }

        {
            "id": 1244,
            "type_of_event": "goal",
            "player": "Djabou",
            "time": "120+4"
        },
        {
            "id": 1249,
            "type_of_event": "goal",
            "player": "Djabou",
            "time": "120+1"
        }

?by_date param produces no result on /match endpoint

Hey, first of all, thanks for the amazing project 😄

My issue here is: I need a way of having the matches organized by stages (e.g. Group Stage, Round of 16, Quarter Finals and so on). I was doing this by just splitting the array I get on http://worldcup.sfg.io/matches–and it worked because it was ordered according to the matches' date.

Turns out that suddenly matches from the knockout stage came before matches from the group one on my responses. Then I decided trying ?by_date=ASC but it doesn't seem to work on /match endpoint, I mean, it produces the very same order on the response payload for ?by_date=ASC and ?by_date=DESC–it works perfectly on /matches/today/, tho.

Any ideas on what's going on?

Results for teams (wins, losses... with the possibility of being grouped together

@estiens :
Hi, It would be possible to give the possibility to the following api call: http://worldcup.sfg.io/teams/results
that the results are grouped by group as in: http://worldcup.sfg.io/teams/group_results

I would use http://worldcup.sfg.io/teams/group_results, but it does not have the following data:
    "wins": 1,
     "draws": 0,
     "losses": 0,
     "games_played": 1,
     "goals_for": 5,
     "goals_against": 0,
     "goal_differential": 5

Counselor something like this: http://worldcup.sfg.io/teams/results?orderBy=group

Add substition-out

The feed now includes information about players that are swapped in, but not those that are swapped out.

Add SSL?

It'd be nice if this api was available over HTTPS.

Half time event

although it isn't a team event, adding half-time event can be greate

Time format decoding

All match start time is returned as :
datetime: "2018-06-15T07:00:00.000-05:00",

Can you please explain to which time zone this time refers to ?
Timing as per FIFA site is just mentioned as Local Time for the above time.
Again Russia has multiple zones.
Unable to derive the time for a country-specific time, for e.g India in my case.

please add a match type

another suggestion: please add a match_type for better sorting.

by the way, I have an app that uses yours, Quiniela, it's a Django fantasy football app which updates scores and users' points with your data.

Missing Events

It seems the scraper isn't getting all events. For example in match_number 1, Croatia has 2 subs in, but 0 subs out. In general I noticed there are many more subs in compared to subs out - I didn't checkout other events.

Past matches being returned as TBD

Matches that have already taken place are being shown as TBD. Could be a problem with the scraping?

Here's an example:

{  
   "venue":"Moscow",
   "location":"Luzhniki Stadium",
   "status":"future",
   "time":null,
   "fifa_id":"300331552",
   "datetime":"2018-07-15T22:00:00Z",
   "last_event_update_at":null,
   "last_score_update_at":null,
   "home_team":{  
      "country":"To Be Determined",
      "code":"TBD",
      "team_tbd":"W61"
   },
   "away_team":{  
      "country":"To Be Determined",
      "code":"TBD",
      "team_tbd":"W62"
   },
   "winner":null,
   "winner_code":null,
   "home_team_events":"no events available for this match",
   "away_team_events":"no events available for this match"
}

When should teams be "knocked out"

Teams have a "knocked-out" option. For the group stages, should teams be knocked out when they are mathematically eliminated from advancing, or only after group play ends?

2018 World cup ?

Hi dude,

I'm wondering if your API will provide data for the upcoming 2018 world cup (men) this summer ?
And if so, is there any release date ?

I would love to use it for a little project in Swift :D
Thanks man !

time scrape error

thanks for the data!
the current match says 1pm ET but it actually started 6pm ET.

[{"match_number":16,"location":"Arena Pantanal","datetime":"2014-06-17T13:00:00.000-05:00","status":"in progress","home_team":{"country":"Russia","code":"RUS","goals":1},"away_team":{"country":"Korea Republic","code":"KOR","goals":1},"winner":null}]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.