Docs / Connect it

Connect a computer

Terminal, PowerShell, Python or Node. Any machine that can make a web request.

$ curl api.chatniai.com/v1/check -H 'Authorization: Bearer pij_…' -d '{"text":"…"}'Terminal, script or spreadsheetNews Intelligencechecks the claimverdict: mostly_trueconfidence: highsources: 3 linkedtext: ready to publishA clear answer comes back
Send text from your computer, read the answer.

1. Keep the key out of your commands

Set it once as an environment variable so it is not pasted into scripts.

SystemCommand
Mac or Linux (this session)export PIJ_KEY=pij_live_YOUR_KEY
Windows PowerShell (this session)$env:PIJ_KEY = "pij_live_YOUR_KEY"
Windows (permanent)Search for Environment Variables in the Start menu and add PIJ_KEY for your user.

2. Send a check

Mac, Linux or Git Bash

curl https://api.chatniai.com/v1/check \
  -H "Authorization: Bearer $PIJ_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"Nigeria has 36 states.","async":true}'

Windows PowerShell

$h = @{ Authorization = "Bearer $env:PIJ_KEY" }
$b = @{ text = "Nigeria has 36 states."; async = $true } | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri https://api.chatniai.com/v1/check -Headers $h -ContentType "application/json" -Body $b

A whole script that waits for the answer (Python)

import os, sys, time, requests
API, H = "https://api.chatniai.com", {"Authorization": "Bearer " + os.environ["PIJ_KEY"]}
text = sys.argv[1]
job = requests.post(API + "/v1/check", headers=H, json={"text": text, "async": True}).json()
if "job_id" not in job: sys.exit(job.get("message", "Could not start"))
for _ in range(90):
    time.sleep(10)
    j = requests.get(API + "/v1/job/" + job["job_id"], headers=H).json()
    if j.get("state") == "done":
        for c in j["result"]["claims"]:
            print(c.get("verdict") or "HELD", "-", c["claim"])
            print(c.get("text") or "")
        break
    if j.get("state") == "failed": sys.exit("Failed. Try again.")

Run it: python check.py "The CBN has closed all banks."

Check a whole file

python check.py "$(cat article.txt)"
TipWindows blocks long text in a command line. For big files, read the file inside the script instead of passing it as an argument.