{
    "schemes": ["https"],
    "swagger": "2.0",
    "info": {
        "description": "This is the API for OpenWeightlifting.org",
        "title": "OpenWeightlifting API",
        "contact": {
            "name": "Euan Meston",
            "email": "euan@openweightlifting.org"
        },
        "version": "1.0"
    },
    "host": "api.openweightlifting.org",
    "basePath": "/",
    "paths": {
        "/events": {
            "get": {
                "description": "Fetch a single event, either by federation and event ID, or by federation and event name. When looking up by name, an optional date can be supplied to filter multi-day events loaded under a single event name.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "GET Requests"
                ],
                "summary": "Fetch a single event",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Federation of the event",
                        "name": "fed",
                        "in": "query",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "ID of the event, required if name is not provided",
                        "name": "id",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Name of the event, required if id is not provided",
                        "name": "name",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Date to filter results by, only applicable when looking up by name",
                        "name": "date",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/structs.LeaderboardResponse"
                        }
                    },
                    "204": {
                        "description": "No Content"
                    }
                }
            }
        },
        "/events/list": {
            "post": {
                "description": "Metadata shows the name, federation and date of the event along with the filename in the event_data folder.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "POST Requests"
                ],
                "summary": "Fetch available event metadata within a set date range",
                "parameters": [
                    {
                        "description": "Date range to filter events by",
                        "name": "request",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/structs.EventSearch"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/structs.EventsList"
                        }
                    },
                    "400": {
                        "description": "Bad Request"
                    }
                }
            }
        },
        "/graph": {
            "get": {
                "description": "This is used within the lifter page to display a lifter's record. It returns a JSON object that can be used with ChartJS without having to do any additional processing.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "GET Requests"
                ],
                "summary": "Retrieve a lifter's record for use with ChartJS on the leaderboard page",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Name of the lifter, must be an exact match",
                        "name": "name",
                        "in": "query",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Federation to filter lifts by",
                        "name": "federation",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/structs.ChartData"
                        }
                    },
                    "204": {
                        "description": "No Content"
                    }
                }
            }
        },
        "/history": {
            "get": {
                "description": "Pull a lifter's history by name. The name must be an exact match and can be checked using the search endpoint.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "GET Requests"
                ],
                "summary": "Retrieve a lifter's history",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Name of the lifter, must be an exact match",
                        "name": "name",
                        "in": "query",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Federation to filter lifts by",
                        "name": "federation",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/structs.LifterHistory"
                        }
                    },
                    "204": {
                        "description": "No Content"
                    }
                }
            }
        },
        "/issue": {
            "post": {
                "description": "Report an issue with a lift to the discord server",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "POST Requests"
                ],
                "summary": "Report an issue with a lift",
                "parameters": [
                    {
                        "description": "Lift to report, along with comments describing the issue",
                        "name": "report",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/structs.LiftReport"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "400": {
                        "description": "Bad Request"
                    }
                }
            }
        },
        "/leaderboard": {
            "get": {
                "description": "This is the used on the index page of the website and pulls the highest single lift for a lifter within the selected filter.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "GET Requests"
                ],
                "summary": "Main table on the index page",
                "parameters": [
                    {
                        "type": "integer",
                        "default": 0,
                        "description": "Position to begin from within the full query",
                        "name": "start",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "default": 50,
                        "description": "Position to stop at within the full query",
                        "name": "stop",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "default": "total",
                        "description": "Sort by either total or sinclair",
                        "name": "sortBy",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Federation or country to filter by",
                        "name": "federation",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "default": "MALL",
                        "description": "Weightclass to filter by",
                        "name": "weightclass",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "Year to filter by, mutually exclusive with startdate/enddate",
                        "name": "year",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Start date to filter from, mutually exclusive with year",
                        "name": "startdate",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "End date to filter to, mutually exclusive with year",
                        "name": "enddate",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/structs.LeaderboardResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request"
                    }
                }
            }
        },
        "/leaderboard/search": {
            "post": {
                "description": "Checks whether a lifter appears within the results of a given leaderboard query and returns their position.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "POST Requests"
                ],
                "summary": "Find a lifter's position within the leaderboard",
                "parameters": [
                    {
                        "description": "Lifter to search for and the leaderboard query to search within",
                        "name": "request",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/structs.SearchLeaderboardRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/structs.SearchLeaderboardResult"
                        }
                    },
                    "400": {
                        "description": "Bad Request"
                    }
                }
            }
        },
        "/rivals": {
            "get": {
                "description": "Returns the lifters ranked immediately around the given lifter, both within their federation (or country) and across all federations combined, for the current competition year.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "GET Requests"
                ],
                "summary": "Find a lifter's closest rivals by total",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Name of the lifter, must be an exact match",
                        "name": "name",
                        "in": "query",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Gender to filter by",
                        "name": "sex",
                        "in": "query",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Federation or country to filter by, defaults to all federations",
                        "name": "fed",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/structs.RivalsCombined"
                        }
                    }
                }
            }
        },
        "/search": {
            "get": {
                "description": "Looks up a lifter by name and returns a list of possible matches. Requires a minimum of 3 characters.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "GET Requests"
                ],
                "summary": "Search through lifter names",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Name to search for, minimum 3 characters",
                        "name": "name",
                        "in": "query",
                        "required": true
                    },
                    {
                        "type": "integer",
                        "default": 50,
                        "description": "Limit the number of results",
                        "name": "limit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/structs.NameSearchResults"
                        }
                    },
                    "204": {
                        "description": "No Content"
                    }
                }
            }
        },
        "/search/similarity": {
            "get": {
                "description": "Returns lifter names that are phonetically or typographically similar to the query. Handles IWF \"LASTNAME Firstname\" format automatically.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "GET Requests"
                ],
                "summary": "Fuzzy search for similar lifter names",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Name to search for",
                        "name": "name",
                        "in": "query",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "Federation the lifter competes in",
                        "name": "federation",
                        "in": "query",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/structs.NameSimilarityResults"
                        }
                    },
                    "204": {
                        "description": "No Content"
                    }
                }
            }
        },
        "/time": {
            "get": {
                "description": "Returns the current server time.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Utilities and Testing"
                ],
                "summary": "Checking the servers localtime",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/structs.ContainerTime"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "structs.ChartData": {
            "type": "object",
            "properties": {
                "datasets": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/structs.ChartSubData"
                    }
                },
                "labels": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "structs.ChartSubData": {
            "type": "object",
            "properties": {
                "data": {
                    "type": "array",
                    "items": {
                        "type": "number"
                    }
                },
                "label": {
                    "type": "string"
                }
            }
        },
        "structs.ContainerTime": {
            "type": "object",
            "properties": {
                "hour": {
                    "type": "integer"
                },
                "min": {
                    "type": "integer"
                },
                "sec": {
                    "type": "integer"
                }
            }
        },
        "structs.Entry": {
            "type": "object",
            "properties": {
                "best_cj": {
                    "$ref": "#/definitions/structs.WeightKg"
                },
                "best_snatch": {
                    "$ref": "#/definitions/structs.WeightKg"
                },
                "bodyweight": {
                    "$ref": "#/definitions/structs.WeightKg"
                },
                "cj_1": {
                    "$ref": "#/definitions/structs.WeightKg"
                },
                "cj_2": {
                    "$ref": "#/definitions/structs.WeightKg"
                },
                "cj_3": {
                    "$ref": "#/definitions/structs.WeightKg"
                },
                "country": {
                    "type": "string"
                },
                "date": {
                    "type": "string"
                },
                "event": {
                    "type": "string"
                },
                "gender": {
                    "type": "string"
                },
                "lifter_name": {
                    "type": "string"
                },
                "sinclair": {
                    "type": "number"
                },
                "snatch_1": {
                    "$ref": "#/definitions/structs.WeightKg"
                },
                "snatch_2": {
                    "$ref": "#/definitions/structs.WeightKg"
                },
                "snatch_3": {
                    "$ref": "#/definitions/structs.WeightKg"
                },
                "total": {
                    "$ref": "#/definitions/structs.WeightKg"
                }
            }
        },
        "structs.EventSearch": {
            "type": "object",
            "properties": {
                "enddate": {
                    "type": "string"
                },
                "startdate": {
                    "type": "string"
                }
            }
        },
        "structs.EventsList": {
            "type": "object",
            "properties": {
                "events": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/structs.SingleEventMetaData"
                    }
                }
            }
        },
        "structs.LeaderboardPayload": {
            "type": "object",
            "properties": {
                "enddate": {
                    "type": "string"
                },
                "federation": {
                    "type": "string"
                },
                "sortby": {
                    "type": "string"
                },
                "start": {
                    "type": "integer"
                },
                "startdate": {
                    "type": "string"
                },
                "stop": {
                    "type": "integer"
                },
                "weightclass": {
                    "type": "string"
                },
                "year": {
                    "type": "string"
                }
            }
        },
        "structs.LeaderboardResponse": {
            "type": "object",
            "properties": {
                "data": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/structs.Entry"
                    }
                },
                "size": {
                    "type": "integer"
                }
            }
        },
        "structs.LiftReport": {
            "type": "object",
            "properties": {
                "comments": {
                    "type": "string"
                },
                "lift": {
                    "$ref": "#/definitions/structs.Entry"
                }
            }
        },
        "structs.LifterHistory": {
            "type": "object",
            "properties": {
                "graph": {
                    "$ref": "#/definitions/structs.ChartData"
                },
                "lifts": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/structs.Entry"
                    }
                },
                "name": {
                    "type": "string"
                },
                "stats": {
                    "$ref": "#/definitions/structs.LifterStats"
                }
            }
        },
        "structs.LifterStats": {
            "type": "object",
            "properties": {
                "best_cj": {
                    "$ref": "#/definitions/structs.WeightKg"
                },
                "best_snatch": {
                    "$ref": "#/definitions/structs.WeightKg"
                },
                "best_total": {
                    "$ref": "#/definitions/structs.WeightKg"
                },
                "make_rate_cj": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                },
                "make_rate_snatches": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                }
            }
        },
        "structs.NameSearch": {
            "type": "object",
            "properties": {
                "federation": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "structs.NameSearchResults": {
            "type": "object",
            "properties": {
                "names": {
                    "description": "todo: refactor this so we don't have to worry about case sensitivity on the items within the slice",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/structs.NameSearch"
                    }
                },
                "total": {
                    "type": "integer"
                }
            }
        },
        "structs.NameSimilarity": {
            "type": "object",
            "properties": {
                "federation": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "score": {
                    "type": "number"
                }
            }
        },
        "structs.NameSimilarityResults": {
            "type": "object",
            "properties": {
                "names": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/structs.NameSimilarity"
                    }
                },
                "total": {
                    "type": "integer"
                }
            }
        },
        "structs.RivalsCombined": {
            "type": "object",
            "properties": {
                "combinedrivals": {
                    "$ref": "#/definitions/structs.RivalsResult"
                },
                "federationrivals": {
                    "$ref": "#/definitions/structs.RivalsResult"
                }
            }
        },
        "structs.RivalsResult": {
            "type": "object",
            "properties": {
                "rivals": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "federation": {
                                "type": "string"
                            },
                            "gender": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            },
                            "position": {
                                "type": "integer"
                            },
                            "total": {
                                "$ref": "#/definitions/structs.WeightKg"
                            }
                        }
                    }
                },
                "total": {
                    "type": "integer"
                }
            }
        },
        "structs.SearchLeaderboardRequest": {
            "type": "object",
            "properties": {
                "active_query": {
                    "$ref": "#/definitions/structs.LeaderboardPayload"
                },
                "lifter_data": {
                    "$ref": "#/definitions/structs.NameSearch"
                }
            }
        },
        "structs.SearchLeaderboardResult": {
            "type": "object",
            "properties": {
                "lifter_data": {
                    "$ref": "#/definitions/structs.NameSearch"
                },
                "position": {
                    "type": "integer"
                },
                "query": {
                    "$ref": "#/definitions/structs.LeaderboardPayload"
                }
            }
        },
        "structs.SingleEventMetaData": {
            "type": "object",
            "properties": {
                "date": {
                    "type": "string"
                },
                "federation": {
                    "type": "string"
                },
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "structs.WeightKg": {
            "type": "object"
        }
    }
}