GithubHelp home page GithubHelp logo

torvaney / wyscoutapi Goto Github PK

View Code? Open in Web Editor NEW
16.0 2.0 3.0 6 KB

wyscoutapi is an extremely basic API client for the Wyscout API (v2 & v3) for Python

License: Other

Python 100.00%
wyscout api soccer-data soccer-data-api

wyscoutapi's Introduction

wyscoutapi

wyscoutapi is an extremely basic API client for the Wyscout API (v2 & v3).

Usage

Install with pip install wyscoutapi.

To connect to the Wyscout v3 api:

import wyscoutapi

client = wyscoutapi.WyscoutAPI(
    username='myusername',
    password='mypassword',
)

client.player(329061)

To use the v2 legacy API, or alter the rate-limit (defaults to 12 requests per second):

import wyscoutapi

client = wyscoutapi.WyscoutAPI(
    username='myusername',
    password='mypassword',
    version='v2',
    requests_per_second=10
)

client.player(329061)

API mocking

It can be useful to mock the API client for testing and local development.

To do this, create a custom "loader" to handle requests, and pass it to the APIClient constructor.

import wyscoutapi


class StubLoader:
    def __init__(self):
        pass

    def get_route_json(self, *route, **params):
        return {
            'stub': 'This is a stub response'
        }
    

client = wyscoutapi.APIClient(loader=StubLoader())
client.player(329061)

Other options

Wyscout provides an OpenAPI specification for their v3 API (see https://apidocs.wyscout.com/). You may prefer to create a more sophisticated API Client using code-generation tools such as openapi-generator or openapi-python-client, although as of 2021-10-01, I had some issues getting this to work with both of the generators linked above.

wyscoutapi's People

Contributors

torvaney avatar

Stargazers

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

Watchers

 avatar  avatar

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.