GithubHelp home page GithubHelp logo

Pagination or getting all records about futbin HOT 1 CLOSED

chenei avatar chenei commented on August 26, 2024
Pagination or getting all records

from futbin.

Comments (1)

matheusfm avatar matheusfm commented on August 26, 2024

Hello, @chenei
Thanks for your comment and sorry for the delay.

Currently, the futbin API that we call to get and filter players only supports up to the 10th page. As can be seen in the example below:

package main

import (
	"fmt"

	"github.com/matheusfm/futbin/players"
)

func main() {
	playersClient := players.DefaultClient()
	var all []players.Player

	for i := 1; i < 100; i++ {
		fmt.Printf("Page %d...\t", i)
		p, err := playersClient.Get(&players.Options{Page: i})
		if err != nil {
			fmt.Printf("ERROR: %v\n", err)
			break
		}
		fmt.Printf("%d players returned\n", len(p))
		if len(p) <= 0 {
			break
		}
		all = append(all, p...)
	}
	fmt.Printf("Total: %d\n", len(all))
}

Output:

$ go run test.go 
Page 1...       32 players returned
Page 2...       32 players returned
Page 3...       32 players returned
Page 4...       32 players returned
Page 5...       32 players returned
Page 6...       32 players returned
Page 7...       32 players returned
Page 8...       32 players returned
Page 9...       32 players returned
Page 10...      32 players returned
Page 11...      0 players returned
Total: 320

The API is https://www.futbin.org/futbin/api/getFilteredPlayers?page=1

from futbin.

Related Issues (4)

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.