Visit us on GitHub

claimbuster_img
Welcome to the ClaimBuster API
To use the API you'll need to request a key if you do not have one.

API - V2 Endpoints
/api/v2/score/text/<input_text>
Parameter Required Type Description
<api_key> True String Your API key which should only be used from your back-end to keep it secret. This should be sent as an x-header, x-api-key, along with the GET/POST request.
<input_text> True String The text you want to score using the ClaimSpotter algorithm.
/api/v2/score/text/sentences/<input_text>
Parameter Required Type Description
<api_key> True String Your API key which should only be used from your back-end to keep it secret. This should be sent as an x-header, x-api-key, along with the GET/POST request.
<input_text> True String Sentences ending with a period to be passed into the claim-spotting algorithm.
/api/v2/query/knowledge_bases/<claim>
Parameter Required Type Description
<api_key> True String Your API key which should only be used from your back-end to keep it secret. This should be sent as an x-header, x-api-key, along with the GET/POST request.
<claim> True String The claim to be fact-checked using knowledge bases.
/api/v2/query/fact_matcher/<claim>
Parameter Required Type Description
<api_key> True String Your API key which should only be used from your back-end to keep it secret. This should be sent as an x-header, x-api-key, along with the GET/POST request.
<claim> True String The claim to be fact-checked using a database of fact-checks.
/api/v2/claim_similarity/simple_similarity/score/claim_a/<claim_a>/claim_b/<claim_b>
Parameter Required Type Description
<api_key> True String Your API key which should only be used from your back-end to keep it secret. This should be sent as an x-header, x-api-key, along with the GET/POST request.
<claim_a> True String The first claim you want to compare.
<claim_b> True String The second claim you want to compare (to the first) .
Getting Started
Best Practices

When using the API you should not expose your API key to the public. In such cases where your application will be exposed to the public, the API call should be made from your back-end in order to not expose your API key and have it used by people other than yourself.

GET Request Example
            
                import requests
                import json

                api_key = "YOUR_API_KEY_HERE"
                input_claim = "The sky is blue."

                # Define the endpoint (url) with the claim formatted as part of it, api-key (api-key is sent as an extra header)
                api_endpoint = f"https://idir.uta.edu/claimbuster/api/v2/score/text/{input_claim}"
                request_headers = {"x-api-key": api_key}

                # Send the GET request to the API and store the api response
                api_response = requests.get(url=api_endpoint, headers=request_headers)

                # Print out the JSON payload the API sent back
                print(api_response.json())
            
        
POST Request Example
            
                import requests
                import json

                api_key = "YOUR_API_KEY_HERE"
                input_claim = "The sky is blue."

                # Define the endpoint (url), payload (sentence to be scored), api-key (api-key is sent as an extra header)
                api_endpoint = "https://idir.uta.edu/claimbuster/api/v2/score/text/"
                request_headers = {"x-api-key": api_key}
                payload = {"input_text": input_claim}

                # Send the POST request to the API and store the api response
                api_response = requests.post(url=api_endpoint, json=payload, headers=request_headers)

                # Print out the JSON payload the API sent back
                print(api_response.json())
            
        
GET Request Example
AJAX
            
                let api_key = 'YOUR_API_KEY_HERE';
                let input_claim = 'The sky is blue.';

                // Setup the AJAX GET Request with the appropriate headers and URL
                $.ajax({
                    type: 'GET',
                    url: `https://idir.uta.edu/claimbuster/api/v2/score/text/${input_claim}`,
                    headers: {
                        'x-api-key': api_key
                    },
                    dataType: 'json',
                    success: function (data) {
                        // Print out the JSON payload the API sent back
                        console.log(JSON.stringify(data, null, 2));
                    }
                });
            
        
Fetch
            
                let api_key = 'YOUR_API_KEY_HERE';
                let input_claim = 'The sky is blue.';

                // Setup the Fetch GET Request with the appropriate headers and URL
                let response = await fetch(`https://idir.uta.edu/claimbuster/api/v2/score/text/${input_claim}`, {
                    method: 'GET',
                    headers: {
                      'x-api-key': api_key,
                    }
                });

                // Print out the JSON payload the API sent back
                console.log(JSON.stringify(response.json(), null, 2));
            
        
POST Request Example
AJAX
            
                let api_key = 'YOUR_API_KEY_HERE';
                let input_claim = 'The sky is blue.';

                // Setup the AJAX POST Request with the appropriate headers, payload, and URL
                $.ajax({
                    type: 'POST',
                    url: 'https://idir.uta.edu/claimbuster/api/v2/score/text/',
                    headers: {
                        'x-api-key': api_key
                    },
                    contentType: 'application/json;charset=UTF-8',
                    data: JSON.stringify({'input_text': input_claim}, null, '\t'),
                    dataType: 'json',
                    success: function (data) {
                        // Print out the JSON payload the API sent back
                        console.log(JSON.stringify(data, null, 2));
                    }
                });
            
        
Fetch
            
                let api_key = 'YOUR_API_KEY_HERE';
                let input_claim = 'The sky is blue.';

                // Setup the Fetch POST Request with the appropriate headers, payload, and URL
                let response = await fetch(url, {
                    method: 'POST',
                    headers: {
                      'Content-Type': 'application/json'
                      'x-api-key': api_key,
                    },
                    body: JSON.stringify({'input_text': input_claim}, null, 2)
                });

                // Print out the JSON payload the API sent back
                console.log(JSON.stringify(response.json(), null, 2));
            
        
GET Request Example
            
                /* Cargo.toml

                [package]
                name = "ClaimBusterApi-DocsExmaple"
                version = "0.1.0"
                authors = ["IDIR Lab "]
                edition = "2021"

                [dependencies]
                error-chain = { version = "0.12.4" }
                tokio = { version = "1.4.0", features = ["full"] }
                reqwest = { version = "0.11.2" }

                */
                use error_chain::error_chain;

                error_chain! {
                    foreign_links {
                        Io(std::io::Error);
                        HttpRequest(reqwest::Error);
                    }
                }

                #[tokio::main]
                async fn main() -> Result<()> {
                    let api_key = "YOUR_API_KEY_HERE";
                    let input_claim = "The sky is blue.";
                    let client = reqwest::Client::new();

                    // Setup the GET request using our Reqwest Client instance with the appropriate headers and URL.
                    let response = client.get(format!("https://idir.uta.edu/claimbuster/api/v2/score/text/{}", input_claim))
                        .header("x-api-key", api_key)
                        .send().await?;

                    println!("Status: {}\n", response.status());
                    println!("Headers:\n{:#?}\n", response.headers());

                    // Print out the JSON payload the API sent back
                    let body = response.text().await?;
                    println!("Body:\n{}", body);

                    Ok(())
                }
            
        
POST Request Example
            
                /* Cargo.toml

                [package]
                name = "ClaimBusterApi-DocsExmaple"
                version = "0.1.0"
                authors = ["IDIR Lab "]
                edition = "2021"

                [dependencies]
                error-chain = { version = "0.12.4" }
                tokio = { version = "1.4.0", features = ["full"] }
                reqwest = { version = "0.11.2", features = ["json"] }

                */
                use error_chain::error_chain;
                use std::collections::HashMap;

                error_chain! {
                    foreign_links {
                        Io(std::io::Error);
                        HttpRequest(reqwest::Error);
                    }
                }

                #[tokio::main]
                async fn main() -> Result<()> {
                    let api_key = "YOUR_API_KEY_HERE";
                    let input_claim = "The sky is blue.";
                    let client = reqwest::Client::new();
                    let mut payload = HashMap::new();

                    payload.insert("input_text", input_claim);
                    // Setup the POST request using our Reqwest Client instance with the appropriate headers, payload, and URL.
                    let response = client.post("https://idir.uta.edu/claimbuster/api/v2/score/text/")
                        .json(&payload)
                        .header("x-api-key", api_key)
                        .send().await?;

                    println!("Status: {}\n", response.status());
                    println!("Headers:\n{:#?}\n", response.headers());

                    // Print out the JSON payload the API sent back
                    let body = response.text().await?;
                    println!("Body:\n{}", body);

                    Ok(())
                }