### Fetch MMA Fights using Go with Native http Source: https://api-sports.io/documentation/mma/v1/index Provides a Go example for retrieving MMA fight data using its native 'net/http' package. It creates an HTTP client, constructs a GET request with the API key header, sends the request, and reads the response body. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://v1.mma.api-sports.io/fights" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return } req.Header.Add("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx") res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) } ``` -------------------------------- ### Fetch MMA Fights using C# with RestSharp Source: https://api-sports.io/documentation/mma/v1/index Shows how to retrieve MMA fight data using C# and the RestSharp library. This example sets up a RestClient, defines a GET request with the necessary API key header, and executes the request, printing the response content. ```csharp var client = new RestClient("https://v1.mma.api-sports.io/fights"); client.Timeout = -1; var request = new RestRequest(Method.GET); request.AddHeader("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx"); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Fetch MMA Fights using Python http.client Source: https://api-sports.io/documentation/mma/v1/index This example demonstrates fetching fight data from the MMA v1 API using Python's built-in http.client library. It establishes an HTTPS connection, sets the required API key in the headers, sends a GET request, and prints the decoded response. No external libraries are needed for this basic implementation. ```python import http.client conn = http.client.HTTPSConnection("v1.mma.api-sports.io") headers = { 'x-apisports-key': "XxXxXxXxXxXxXxXxXxXxXxXx" } conn.request("GET", "/fights", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Get MMA Fighters using PHP Source: https://api-sports.io/documentation/mma/v1/index This PHP example shows how to fetch MMA fighter data using the API-SPORTS v1 API. It demonstrates setting the API key and an example query parameter for fighter ID. The endpoint can also filter by team, name, category, or search. ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.mma.api-sports.io/fighters'); $request->setRequestMethod('GET'); $request->setQuery(new http\QueryString(array( 'id' => '691' ))); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` -------------------------------- ### Fetch MMA Fights using cURL Source: https://api-sports.io/documentation/mma/v1/index A command-line example using cURL to fetch MMA fight data. It specifies the GET request method, the API endpoint URL, and includes the required 'x-apisports-key' header. ```bash curl --request GET \ --url https://v1.mma.api-sports.io/fights \ --header 'x-apisports-key: XxXxXxXxXxXxXxXxXxXxXxXx' ``` -------------------------------- ### GET /fights Source: https://api-sports.io/documentation/mma/v1/index Fetches a list of MMA fights. Requires an API key for authentication. ```APIDOC ## GET /fights ### Description Fetches a list of MMA fights. Requires an API key for authentication. ### Method GET ### Endpoint https://v1.mma.api-sports.io/fights ### Parameters #### Headers - **x-apisports-key** (string) - Required - Your API key for authentication. ### Request Example ``` GET https://v1.mma.api-sports.io/fights Headers: x-apisports-key: XxXxXxXxXxXxXxXxXxXxXxXx ``` ### Response #### Success Response (200) - **response** (object) - Contains the fight data. #### Response Example ```json { "response": [ { "fight_id": 12345, "fighter1": "Fighter Name 1", "fighter2": "Fighter Name 2", "date": "2023-10-27", "event": "Example Event" } ] } ``` ``` -------------------------------- ### Fetch Fights Data (Sample Scripts) Source: https://api-sports.io/documentation/mma/v1/index Demonstrates how to fetch fight data using the API. Replace `{endpoint}` with 'fights' and `XxXxXxXxXxXxXxXxXxXxXx` with your API key. This is a general example applicable across multiple languages. ```cURL curl --request GET \ --url 'https://v1.mma.api-sports.io/fights' \ --header 'x-apisports-key: XxXxXxXxXxXxXxXxXxXxXx' ``` ```javascript fetch('https://v1.mma.api-sports.io/fights', { "method": "GET", "headers": { "x-apisports-key": "XxXxXxXxXxXxXxXxXxXxXx" } }) .then(response => response.json()) .then(response => console.log(response)) .catch(error => console.log(error)); ``` ```php $client = new GuzzleHttpClient(); $response = $client->request('GET', 'https://v1.mma.api-sports.io/fights', [ 'headers' => [ 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXx', ], ]); echo $response->getBody(); ``` ```python import requests url = "https://v1.mma.api-sports.io/fights" headers = { 'x-apisports-key': "XxXxXxXxXxXxXxXxXxXxXx" } response = requests.get(url, headers=headers) print(response.json()) ``` ```powershell $apiKey = "XxXxXxXxXxXxXxXxXxXxXx" $apiUrl = "https://v1.mma.api-sports.io/fights" $headers = @{ "x-apisports-key" = $apiKey } $response = Invoke-RestMethod -Method Get -Uri $apiUrl -Headers $headers $response | ConvertTo-Json ``` -------------------------------- ### GET /fights Source: https://api-sports.io/documentation/mma/v1/index Retrieves a list of all MMA fights. Requires an API key for authentication. ```APIDOC ## GET /fights ### Description Retrieves a list of all MMA fights. Requires an API key for authentication. ### Method GET ### Endpoint https://v1.mma.api-sports.io/fights ### Parameters #### Query Parameters - **apikey** (string) - Required - Your API key for authentication. ### Request Example ``` GET /fights?apikey=YOUR_API_KEY ``` ### Response #### Success Response (200) - **data** (array) - An array of fight objects. - **fight_id** (integer) - The unique identifier for the fight. - **fight_date** (string) - The date of the fight (YYYY-MM-DD). - **promotion** (string) - The name of the MMA promotion. - **event_name** (string) - The name of the fight event. - **fighter1** (object) - Details about the first fighter. - **name** (string) - The fighter's name. - **record** (string) - The fighter's win-loss-draw record. - **fighter2** (object) - Details about the second fighter. - **name** (string) - The fighter's name. - **record** (string) - The fighter's win-loss-draw record. - **winner** (string) - The name of the winning fighter (or null if no contest). - **method** (string) - The method of victory (e.g., "KO", "Decision"). - **round** (integer) - The round in which the fight ended. - **time_format** (string) - The time of the stoppage within the round (e.g., "1:35"). #### Response Example ```json { "data": [ { "fight_id": 12345, "fight_date": "2023-10-27", "promotion": "UFC", "event_name": "UFC 294", "fighter1": { "name": "Islam Makhachev", "record": "25-1" }, "fighter2": { "name": "Alexander Volkanovski", "record": "26-3" }, "winner": "Islam Makhachev", "method": "KO", "round": 1, "time_format": "1:07" } ] } ``` #### Error Response (401) - **message** (string) - Error message indicating unauthorized access (e.g., "Invalid API Key"). #### Error Response Example ```json { "message": "Invalid API Key" } ``` ``` -------------------------------- ### GET /mma/v1/fights Source: https://api-sports.io/documentation/mma/v1/index Retrieve a list of MMA fights. You can filter fights by date. ```APIDOC ## GET /mma/v1/fights ### Description Retrieve a list of MMA fights. You can filter fights by date. ### Method GET ### Endpoint /mma/v1/fights ### Parameters #### Query Parameters - **date** (string) - Optional - The date to filter fights by (e.g., "2023-08-26"). ### Request Example ```json { "date": "2023-08-26" } ``` ### Response #### Success Response (200) - **get** (string) - The type of data returned ('fights'). - **parameters** (object) - The parameters used for the request. - **date** (string) - The requested date. - **errors** (array) - An array of errors, if any. - **results** (integer) - The total number of fights found. - **response** (array) - An array of fight objects. - **id** (integer) - The unique identifier for the fight. - **date** (string) - The date and time of the fight. - **time** (string) - The time of the fight. - **timestamp** (integer) - The Unix timestamp of the fight. - **timezone** (string) - The timezone of the fight. - **slug** (string) - A slug representing the event. - **is_main** (boolean) - Indicates if the fight is a main event. - **category** (string) - The weight category of the fight. - **status** (object) - The status of the fight. - **long** (string) - A long description of the status (e.g., 'Finished'). - **short** (string) - A short description of the status (e.g., 'FT'). - **fighters** (object) - Information about the fighters in the bout. - **first** (object) - Details of the first fighter. - **id** (integer) - The fighter's ID. - **name** (string) - The fighter's name. - **logo** (string) - The URL of the fighter's logo. - **winner** (boolean) - Indicates if this fighter won. - **second** (object) - Details of the second fighter. - **id** (integer) - The fighter's ID. - **name** (string) - The fighter's name. - **logo** (string) - The URL of the fighter's logo. - **winner** (boolean) - Indicates if this fighter won. #### Response Example ```json { "get": "fights", "parameters": { "date": "2023-08-26" }, "errors": [], "results": 13, "response": [ { "id": 878, "date": "2023-08-26T09:00:00+00:00", "time": "09:00", "timestamp": 1693040400, "timezone": "UTC", "slug": "UFC Fight Night: Holloway vs. The Korean Zombie", "is_main": false, "category": "Featherweight", "status": { "long": "Finished", "short": "FT" }, "fighters": { "first": { "id": 2495, "name": "Jarno Errens", "logo": "https://media-1.api-sports.io/mma/teams/2495.png", "winner": false }, "second": { "id": 390, "name": "SeungWoo Choi", "logo": "https://media-1.api-sports.io/mma/teams/390.png", "winner": true } } } ] } ``` ``` -------------------------------- ### Fetch MMA Fights using Dart with http Source: https://api-sports.io/documentation/mma/v1/index Illustrates fetching MMA fight data in Dart using the 'http' package. The code constructs a GET request, adds the API key header, sends the request, and prints the response body if successful, or the reason phrase otherwise. ```dart var headers = { 'x-apisports-key': 'XxXxXxXxXxXxXxXxXxXxXxXx', }; var request = http.Request('GET', Uri.parse('https://v1.mma.api-sports.io/fights')); request.headers.addAll(headers); http.StreamedResponse response = await request.send(); if (response.statusCode == 200) { print(await response.stream.bytesToString()); } else { print(response.reasonPhrase); } ``` -------------------------------- ### Fetch MMA Fights using Python Requests Source: https://api-sports.io/documentation/mma/v1/index This Python snippet utilizes the popular 'Requests' library to fetch fight data from the MMA v1 API. It defines the request URL, payload (empty in this case), and headers including the API key. The response text is then printed. Ensure the 'requests' library is installed (`pip install requests`). ```python import requests url = "https://v1.mma.api-sports.io/fights" payload={} headers = { 'x-apisports-key': 'XxXxXxXxXxXxXxXxXxXxXxXx', } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Fetch MMA Fights using Java with OkHttp and Unirest Source: https://api-sports.io/documentation/mma/v1/index This section shows two ways to fetch MMA fight data in Java. The first uses OkHttp to prepare request options including headers. The second uses Unirest to send a GET request with the API key header and retrieve the response as a string. ```java var myHeaders = new Headers(); myHeaders.append("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; ``` ```java Unirest.setTimeouts(0, 0); HttpResponse response = Unirest.get("https://v1.mma.api-sports.io/fights") .header("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx") .asString(); ``` -------------------------------- ### Fetch MMA Fights using Ruby Net::HTTP Source: https://api-sports.io/documentation/mma/v1/index This Ruby code snippet uses the Net::HTTP library to make a GET request to the MMA v1 API. It requires 'uri', 'net/http', and 'openssl'. The code sets up the URL, establishes an SSL connection, adds the API key to the request headers, and prints the response body. OpenSSL verification is disabled for simplicity. ```ruby require 'uri' require 'net/http' require 'openssl' url = URI("https://v1.mma.api-sports.io/fights") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(url) request["x-apisports-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx' response = http.request(request) puts response.read_body ``` -------------------------------- ### GET /status Source: https://api-sports.io/documentation/mma/v1/index Retrieves the status of your API account, subscription plan, and request limits. This call does not consume your daily quota. ```APIDOC ## GET /status ### Description Retrieves the status of your API account, subscription plan, and request limits. This call does not consume your daily quota. ### Method GET ### Endpoint /status ### Parameters #### Query Parameters None #### Request Body None ### Request Example ``` GET https://v1.mma.api-sports.io/status Header: x-apisports-key: XxXxXxXxXxXxXxXxXxXxXxXx ``` ### Response #### Success Response (200) - **get** (string) - The type of response, 'status'. - **parameters** (array) - An empty array for this endpoint. - **errors** (array) - An empty array for this endpoint. - **results** (integer) - The number of results, typically 1 for status. - **response** (object) - Contains account, subscription, and requests information. - **account** (object) - **firstname** (string) - User's first name. - **lastname** (string) - User's last name. - **email** (string) - User's email address. - **subscription** (object) - **plan** (string) - The subscription plan name (e.g., 'Free'). - **end** (string) - The subscription end date and time. - **active** (boolean) - Indicates if the subscription is active. - **requests** (object) - **current** (integer) - The number of requests made today. - **limit_day** (integer) - The daily request limit. #### Response Example ```json { "get": "status", "parameters": [], "errors": [], "results": 1, "response": { "account": { "firstname": "xxxx", "lastname": "XXXXXX", "email": "xxx@xxx.com" }, "subscription": { "plan": "Free", "end": "2020-04-10T23:24:27+00:00", "active": true }, "requests": { "current": 12, "limit_day": 100 } } } ``` ``` -------------------------------- ### Fetch MMA Fights using Shell wget Source: https://api-sports.io/documentation/mma/v1/index This shell command uses 'wget' to retrieve fight data from the MMA v1 API. It disables certificate checking, quiets the output, sets a GET method, specifies a timeout, and includes the necessary API key in the headers. This is a common method for downloading content from the command line. ```shell wget --no-check-certificate --quiet \ --method GET \ --timeout=0 \ --header 'x-apisports-key: XxXxXxXxXxXxXxXxXxXxXxXx' \ 'https://v1.mma.api-sports.io/fights' ``` -------------------------------- ### Fetch MMA Fights using PowerShell Source: https://api-sports.io/documentation/mma/v1/index This snippet shows how to retrieve fight data from the MMA v1 API using PowerShell's Invoke-RestMethod. It includes setting up necessary headers, making the GET request, and converting the response to JSON. Ensure you have a valid 'x-apisports-key'. ```powershell $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx") $response = Invoke-RestMethod 'https://v1.mma.api-sports.io/fights' -Method 'GET' -Headers $headers $response | ConvertTo-Json ``` -------------------------------- ### Fetch MMA Fights using Swift URLSession Source: https://api-sports.io/documentation/mma/v1/index This Swift code demonstrates fetching fight data from the MMA v1 API using URLSession. It configures a URLRequest with the API endpoint and the 'x-apisports-key' header. A data task is created to perform the GET request, and the response data is printed as a UTF-8 string. Includes conditional import for FoundationNetworking on certain platforms. ```swift import Foundation #if canImport(FoundationNetworking) import FoundationNetworking #endif var semaphore = DispatchSemaphore (value: 0) var request = URLRequest(url: URL(string: "https://v1.mma.api-sports.io/fights")!,timeoutInterval: Double.infinity) request.addValue("XxXxXxXxXxXxXxXxXxXxXxXx", forHTTPHeaderField: "x-apisports-key") request.httpMethod = "GET" let task = URLSession.shared.dataTask(with: request) { data, response, error in guard let data = data else { print(String(describing: error)) semaphore.signal() return } print(String(data: data, encoding: .utf8)!) semaphore.signal() } task.resume() semaphore.wait() ``` -------------------------------- ### Fetch MMA Fights using Javascript with Fetch, jQuery, and XHR Source: https://api-sports.io/documentation/mma/v1/index This snippet provides three Javascript methods for fetching MMA fight data: using the Fetch API, jQuery's AJAX method, and the native XMLHttpRequest (XHR). All methods demonstrate setting the GET request and the 'x-apisports-key' header. ```javascript var myHeaders = new Headers(); myHeaders.append("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://v1.mma.api-sports.io/fights", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` ```javascript var settings = { "url": "https://v1.mma.api-sports.io/fights", "method": "GET", "timeout": 0, "headers": { "x-apisports-key": "XxXxXxXxXxXxXxXxXxXxXxXx", }, }; $.ajax(settings).done(function (response) { console.log(response); }); ``` ```javascript var xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function() { if(this.readyState === 4) { console.log(this.responseText); } }); xhr.open("GET", "https://v1.mma.api-sports.io/fights"); xhr.setRequestHeader("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx"); xhr.send(); ``` -------------------------------- ### GET /fighters/records Source: https://api-sports.io/documentation/mma/v1/index Retrieves the career statistics for a specific MMA fighter. This endpoint requires a fighter ID and an API key. ```APIDOC ## GET /fighters/records ### Description Return the fighter's career statistics. ### Method GET ### Endpoint https://v1.mma.api-sports.io/fighters/records ### Parameters #### Query Parameters - **id** (integer) - Required - The id of the fighter #### Header Parameters - **x-apisports-key** (string) - Required - Your API-SPORTS Key ### Request Example ```json { "get": "fighters/records", "parameters": { "id": "691" } } ``` ### Response #### Success Response (200) - **get** (string) - Endpoint name. - **parameters** (object) - Query parameters used. - **errors** (array) - Array of errors, if any. - **results** (integer) - Number of results. - **response** (array) - Array of fighter record objects. - **fighter** (object) - **id** (integer) - Fighter's ID. - **name** (string) - Fighter's name. - **photo** (string) - URL to the fighter's photo. - **total** (object) - **win** (integer) - Total wins. - **loss** (integer) - Total losses. - **draw** (integer) - Total draws. - **ko** (object) - **win** (integer) - Wins by Knockout. - **loss** (integer) - Losses by Knockout. - **sub** (object) - **win** (integer) - Wins by Submission. - **loss** (integer) - Losses by Submission. #### Response Example ```json { "get": "fighters/records", "parameters": { "id": "691" }, "errors": [], "results": 1, "response": [ { "fighter": { "id": 691, "name": "Conor McGregor", "photo": "https://media-1.api-sports.io/mma/fighters/691.png" }, "total": { "win": 22, "loss": 6, "draw": 0 }, "ko": { "win": 19, "loss": 2 }, "sub": { "win": 1, "loss": 4 } } ] } ``` ``` -------------------------------- ### Fetch MMA Fights using Shell Httpie Source: https://api-sports.io/documentation/mma/v1/index This shell command uses the 'Httpie' tool to make a GET request to the MMA v1 API for fight data. It includes options for following redirects, setting a timeout, specifying the HTTP method, and passing the 'x-apisports-key' header. Httpie is a user-friendly command-line HTTP client. ```shell http --follow --timeout 3600 GET 'https://v1.mma.api-sports.io/fights' \ x-apisports-key:'XxXxXxXxXxXxXxXxXxXxXxXx' \ ``` -------------------------------- ### GET /fights Source: https://api-sports.io/documentation/mma/v1/index Retrieves a list of fights based on specified parameters such as date, season, fighter ID, or category. Supports timezone filtering. ```APIDOC ## GET /fights ### Description Return the list of fights according to the given parameters. ### Method GET ### Endpoint https://v1.mma.api-sports.io/fights ### Parameters #### Query Parameters - **id** (integer) - The id of the fight. - **date** (string) - Default: "YYYY-MM-DD". Example: date=2023-08-26. A valid date. - **season** (integer) - Default: "YYYY". Example: season=2023. A valid season. - **fighter** (integer) - The id of the fighter. - **category** (string) - Example: category=Flyweight. The name of the category. - **timezone** (string) - Example: timezone=Europe/London. A valid timezone. If not recognized or omitted, "UTC" will be applied. #### Header Parameters - **x-apisports-key** (string) - Required - Your API-SPORTS Key ### Available Statuses - **NS**: Not Started - **IN**: Intros - **PF**: Pre-fight - **LIVE**: In Progress - **EOR**: End of Round - **FT**: Finished - **WO**: Walkouts - **CANC**: Cancelled (Fight cancelled and not rescheduled) - **PST**: Postponed (Fight postponed and waiting for a new Fight date) ### Responses #### Success Response (200) OK #### Response Example (Example response structure not provided in the input, but would typically include a list of fight objects with details like fighters, outcomes, dates, etc.) ### Request Example (PHP) ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.mma.api-sports.io/fights'); $request->setRequestMethod('GET'); $request->setQuery(new http\QueryString(array( 'date' => '2023-08-26' ))); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` ``` -------------------------------- ### GET /odds/bets Source: https://api-sports.io/documentation/mma/v1/index Retrieves a list of available bet types for MMA odds. These bet types can be used to filter odds requests. ```APIDOC ## GET /odds/bets ### Description Retrieves a list of available bet types for MMA odds. The IDs returned can be used to filter odds requests. ### Method GET ### Endpoint /odds/bets ### Parameters There are no specific parameters for this endpoint. It returns a comprehensive list of all available bet types. #### Header Parameters - **x-apisports-key** (string) - Required - Your API-SPORTS Key. ### Request Example ```json { "example": "" } ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier for the bet type. - **name** (string) - The name of the bet type. #### Response Example ```json { "get": "odds/bets", "parameters": [], "errors": [], "results": 20, "response": [ { "id": 1, "name": "3Way Result" }, { "id": 2, "name": "Home/Away" } // ... more bet types ] } ``` ``` -------------------------------- ### Get Odds Bet Types (JSON Response Sample) Source: https://api-sports.io/documentation/mma/v1/index This is a sample JSON response for the 'odds/bets' endpoint, illustrating the available bet types for MMA fights. It includes the ID and name for each bet type. ```json { "get": "odds/bets", "parameters": [], "errors": [], "results": 20, "response": [ { "id": 1, "name": "3Way Result" }, { "id": 2, "name": "Home/Away" }, { "id": 3, "name": "Asian Handicap" }, { "id": 4, "name": "Over/Under" }, { "id": 5, "name": "Fight To Go the Distance" }, { "id": 6, "name": "Round Betting" }, { "id": 7, "name": "Fight To Start Round 2" }, { "id": 8, "name": "Fight To Start Round 3" }, { "id": 9, "name": "Fight To Start Round 4" }, { "id": 10, "name": "Fight To Start Round 5" }, { "id": 11, "name": "Win by Unanimous Decisio" }, { "id": 12, "name": "Win by Split or Majority Decision" }, { "id": 13, "name": "Home Win by Unanimous Decision" }, { "id": 14, "name": "Home Win by Split or Majority Decision" }, { "id": 15, "name": "Away Win by Unanimous Decision" }, { "id": 16, "name": "Away Win by Split or Majority Decision" }, { "id": 17, "name": "Home Win by Submission" }, { "id": 18, "name": "Home Win by KO/TKO/DQ" }, { "id": 19, "name": "Away Win by Submission" }, { "id": 20, "name": "Away Win by KO/TKO/DQ" } ] } ``` -------------------------------- ### Get Fights List (PHP) Source: https://api-sports.io/documentation/mma/v1/index Retrieves a list of MMA fights based on specified query parameters such as date, season, fighter ID, category, or timezone. Requires an API-SPORTS key for authentication. Fights are updated every 30 seconds. ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.mma.api-sports.io/fights'); $request->setRequestMethod('GET'); $request->setQuery(new http\QueryString(array( 'date' => '2023-08-26' ))); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` -------------------------------- ### Fetch MMA Fights using Cohttp in OCaml Source: https://api-sports.io/documentation/mma/v1/index Fetches MMA fight data from the API Sports v1 API using the Cohttp library in OCaml. This code defines a function to make the GET request with the necessary headers and returns the response body as a string. It then runs this function and prints the result. ```ocaml open Lwt open Cohttp open Cohttp_lwt_unix let reqBody = let uri = Uri.of_string "https://v1.mma.api-sports.io/fights" in let headers = Header.init () |> fun h -> Header.add h "x-apisports-key" "XxXxXxXxXxXxXxXxXxXxXxXx" in Client.call ~headers `GET uri >|= fun (_resp, body) -> body |> Cohttp_lwt.Body.to_string let () = let respBody = Lwt_main.run reqBody in print_endline (respBody) ``` -------------------------------- ### Get Fighter Records (PHP) Source: https://api-sports.io/documentation/mma/v1/index Fetches the career statistics for a given MMA fighter using their ID. This endpoint requires an API-SPORTS key and returns win, loss, and draw records, including KO and submission statistics. The data is updated daily. ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.mma.api-sports.io/fighters/records'); $request->setRequestMethod('GET'); $request->setQuery(new http\QueryString(array( 'id' => '691' ))); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` -------------------------------- ### Fetch Available Bets - PHP Source: https://api-sports.io/documentation/mma/v1/index This PHP code snippet shows how to retrieve a list of available bets for MMA odds. It sends a GET request to the '/odds/bets' endpoint, requiring your API-SPORTS key in the headers. You can optionally filter bets by ID or search by name. ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.mma.api-sports.io/odds/bets'); $request->setRequestMethod('GET'); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` -------------------------------- ### PHP Request for Categories Endpoint Source: https://api-sports.io/documentation/mma/v1/index This PHP code snippet demonstrates fetching available categories from the API-SPORTS MMA v1 API. It configures an HTTP client to send a GET request to the '/categories' endpoint, including the required 'x-apisports-key' header. The API response containing category information is then displayed. ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.mma.api-sports.io/categories'); $request->setRequestMethod('GET'); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` -------------------------------- ### Fetch MMA Fights using C with libcurl Source: https://api-sports.io/documentation/mma/v1/index Demonstrates how to fetch MMA fight data using C and the libcurl library. It involves initializing a curl handle, setting the request method, URL, and headers, then performing the request and cleaning up. ```c CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET"); curl_easy_setopt(curl, CURLOPT_URL, "https://v1.mma.api-sports.io/fights"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "x-apisports-key: XxXxXxXxXxXxXxXxXxXxXxXx"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); res = curl_easy_perform(curl); } crl_easy_cleanup(curl); ``` -------------------------------- ### Get MMA Teams using PHP Source: https://api-sports.io/documentation/mma/v1/index This PHP code retrieves a list of MMA teams from the API-SPORTS v1 API. It shows how to set the API key in the headers and make a GET request to the teams endpoint. The response contains team IDs and names. ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.mma.api-sports.io/teams'); $request->setRequestMethod('GET'); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` -------------------------------- ### HTML Widget Usage with Custom Themes Source: https://api-sports.io/documentation/mma/v1/index This HTML demonstrates how to use the api-sports-widget with a custom theme. It shows the basic widget for games and a configured widget for game data, applying the 'MyTheme' defined in CSS. Ensure you replace 'Your-Api-Key-Here' with your actual API key. ```html
``` -------------------------------- ### GET /teams Source: https://api-sports.io/documentation/mma/v1/index Retrieves a list of all available MMA teams. The team IDs are unique and can be used in other endpoints. ```APIDOC ## GET /teams ### Description Retrieves the list of available teams. The team `id` is unique in the API. ### Method GET ### Endpoint /teams ### Parameters #### Query Parameters - **id** (integer) - Optional - The ID of the team. - **search** (string) - Optional - A search query for the team name (minimum 3 characters). #### Header Parameters - **x-apisports-key** (string) - Required - Your API-SPORTS Key. ### Request Example ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.mma.api-sports.io/teams'); $request->setRequestMethod('GET'); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` ### Response #### Success Response (200) - **get** (string) - The endpoint called. - **parameters** (array) - An array of query parameters used. - **errors** (array) - An array of errors encountered. - **results** (integer) - The total number of results. - **response** (array) - An array of team objects. - **id** (integer) - The unique ID of the team. - **name** (string) - The name of the team. #### Response Example ```json { "get": "teams", "parameters": [], "errors": [], "results": 722, "response": [ { "id": 1, "name": "MMA LAB" }, { "id": 2, "name": "Fortis MMA" } ] } ``` ``` -------------------------------- ### GET /odds Source: https://api-sports.io/documentation/mma/v1/index Retrieves odds for MMA fights. You can filter by fight ID, date, bookmaker, or bet ID. ```APIDOC ## GET /odds ### Description Retrieves odds for MMA fights. This endpoint can be filtered by fight ID, date, bookmaker ID, or bet ID. ### Method GET ### Endpoint https://v1.mma.api-sports.io/odds ### Parameters #### Query Parameters - **fight** (integer) - Optional - The id of the fight - **date** (string) - Optional - Default: "YYYY-MM-DD". Example: date=2023-08-26. A valid date. - **bookmaker** (integer) - Optional - The id of the bookmaker - **bet** (integer) - Optional - The id of the bet #### Header Parameters - **x-apisports-key** (string) - Required - Your API-SPORTS Key ### Request Example ```json { "fight": "878" } ``` ### Response #### Success Response (200) - **get** (string) - The endpoint called ('odds') - **parameters** (object) - The parameters used for the request - **errors** (array) - An array of errors, if any - **results** (integer) - The number of results returned - **response** (array) - An array of fight odds data #### Response Example ```json { "get": "odds", "parameters": { "bookmaker": "2", "fight": "878" }, "errors": [], "results": 1, "response": [ { "fight": { "id": 878 }, "bookmakers": [ { "id": 2, "name": "bwin", "bets": [ { "id": 2, "name": "Home/Away", "values": [ { "value": "Home", "odd": "2.30" }, { "value": "Away", "odd": "1.63" } ] } ] } ] } ] } ``` ```