sorare / api

Sorare API documentation
154 stars 49 forks source link

Query to get all player names #285

Open andreagiovanesorare opened 2 years ago

andreagiovanesorare commented 2 years ago

Hi, it seems that there is no query to get the list of all players inside Sorare both those that have club and also those not. I can get a player information with his slug but it's difficult guess the player's slug. Can you help me? How can I get the full list of players with their slugs and display names?

kykp commented 2 years ago

Hello, you can use all the cards, or check the active clubs for their players

andreagiovanesorare commented 2 years ago

Thank you for your answer

nachoroncero commented 2 years ago

Hello, did you get to find the players using the active clubs?

andreagiovanesorare commented 2 years ago

No, I used all the cards query because for active clubs you need the slug of club.

RafaelBetoulle commented 2 years ago

Hey ! I used the clubs and active players and got 100,000 players, looking at SorareData I saw there were over 400,000 players. By retrieving all the cards I can only retrieve them 50 by 50, it's extremely long and I still have to retrieve the player, how did you manage to retrieve all the players easily? Also do you know to see the exact number of players on Sorare? Thanks !

andreagiovanesorare commented 2 years ago

Hi, it's the same for me. I don't know a good way to do. I retrieve players 50 at time.

jamb0ree commented 2 years ago

I don't think you can by-pass the "50 by 50" retrieval of all players. As a quick workaround, I am using the allCards endpoint, but filtering only cards with a serial number of 1, and with a limited rarity. I know I don't have each and everyone player (because some players have rare cards but no limited), but I get most of them (and it's enough for me for now) ; but I guess you could do the same with every other rarity. The query I am using (looping through every endCursor variable) :

query($endCursor: String!) {
  allCards(
    rarities: [limited]
    owned: true
    serialNumber: 1
    after: $endCursor
  ) {
    nodes {
      player {
        slug
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}

As a result, I get around 13700 distinct players that have at least a n°1 limited card.

RafaelBetoulle commented 2 years ago

Thank you for your answer, from what I had seen there were many more players than that on SorareData but I may have been wrong! I will try to retrieve them all with your query and I will see how many I have 😁

dirtyhenry commented 7 months ago

In case you need to scope things a little more, this is what I used to fetch all MLB players:

{
  ARI: baseballTeam(slug: "arizona-diamondbacks") {
    name
    players {
      displayName
      slug
    }
  }
 …
  WSH: baseballTeam(slug: "washington-nationals") {
    name
    players {
      displayName
      slug
    }
  }
}