Coder Social home page Coder Social logo

cricket-api's Introduction

Cricket Match Management API

The Cricket Match Management API is a Flask-based web application designed to manage cricket match data, teams, players, and more. It provides endpoints for registering admin users, managing matches, and retrieving match schedules.

Table of Contents

Installation

  1. Clone the repository to your local machine:

    git clone https://github.com/yourusername/workindia.git
  2. Install the required dependencies using pip:

    pip install -r requirements.txt
  3. Configure the database connection and secret key in app.py:

    app.config['SQLALCHEMY_DATABASE_URI'] = 'your_database_uri_here'
    app.config['SECRET_KEY'] = 'your_secret_key_here'
  4. Run the application:

    python app.py

Usage

1. Register Admin

  • Endpoint: [POST] /api/admin/signup

  • Request Data:

    {
        "username": "example_user",
        "password": "example_password",
        "email": "[email protected]"
    }
  • Response Data:

    {
        "status": "Admin Account successfully created",
        "status_code": 200,
        "user_id": "12345"
    }

2. Login User

  • Endpoint: [POST] /api/admin/login

  • Request Data:

    {
        "username": "example_user",
        "password": "example_password"
    }
  • Successful Login Response:

    {
        "status": "Login successful",
        "status_code": 200,
        "user_id": "12345",
        "access_token": "your_access_token_here"
    }
  • Failure Response:

    {
        "status": "Incorrect username/password provided. Please retry",
        "status_code": 401
    }

3. Create Match

  • Endpoint: [POST] /api/matches

  • Headers:

    {
        "Authorization": "Bearer your_access_token_here"
    }
  • Request Data:

    {
        "team_1": "India",
        "team_2": "Australia",
        "date": "2023-07-12",
        "venue": "Sydney Cricket Ground"
    }
  • Response Data:

    {
        "message": "Match created successfully",
        "match_id": "3"
    }

4. Get Match Schedules

  • Endpoint: [GET] /api/matches

  • Request Data: None

  • Response Data:

    {
        "matches": [
            {
                "match_id": "1",
                "team_1": "India",
                "team_2": "England",
                "date": "2023-07-10",
                "venue": "Lord's Cricket Ground"
            },
            {
                "match_id": "2",
                "team_1": "Australia",
                "team_2": "New Zealand",
                "date": "2023-07-11",
                "venue": "Melbourne Cricket Ground"
            }
            // Add more matches here
        ]
    }

6. Add a Team Member to a Squad

  • Endpoint: [POST] /api/teams/{team_id}/squad

  • Request Data:

    {
        "name": "Rishabh Pant",
        "role": "Wicket-Keeper"
    }
  • Response Data:

    {
        "message": "Player added to squad successfully",
        "player_id": "789"
    }

Database

The API uses a PostgreSQL database to store user, team, player, match, and player statistics data. You can configure the database connection in the app.py file.

Authentication

Authentication is implemented using JWT (JSON Web Tokens). Admin users receive access tokens upon login, which are required to access admin-only endpoints.

Contributing

Contributions to the Cricket Match Management API are welcome! You can contribute by opening issues, creating pull requests, or suggesting improvements.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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.