Skip to content
datasportsAPI

DsCommand line

Every endpoint, one command away.

The dsa command is built on the Go SDK. Each endpoint becomes dsa <group> <action>, output comes as JSON, JSON lines, a table or CSV, and any WebSocket channel can be watched live from the terminal.

Command
dsa
Runs on
macOS · Linux · Windows
Key
DATASPORTSAPI_API_KEY
Status
Not published yet
Install
$ go install github.com/datasportsapi/datasportsapi-go/cmd/dsa@latest

The install line goes live with the first release; nothing is on a public registry yet. Everything on this page describes the client as it will ship.

  1. Install

    The CLI ships in the Go module as a command. With Go installed, one line puts it on your PATH.

    shell
    $ go install github.com/datasportsapi/datasportsapi-go/cmd/dsa@latest
    $ dsa --help
  2. Sign in

    dsa login asks for your key, checks it with a single call and keeps it in the operating system's keychain. --api-key and DATASPORTSAPI_API_KEY both win over the stored key, which suits CI.

    shell
    $ dsa login    # prompts for the key, verifies it, stores it in the keychain
    $ dsa logout   # removes it again
    
    # CI: no login needed
    $ DATASPORTSAPI_API_KEY=dsa_live_… dsa sports list
  3. Call any endpoint

    dsa <group> <action> exists for every endpoint in the docs. Path parameters are arguments, query parameters are flags with the API's own names.

    shell
    $ dsa livescores list --sport football -o table
    $ dsa fixtures lineups 480112
    $ dsa leagues standings 17 --season 76986 -o csv > table.csv
    $ dsa search query "real madrid" --fields id,type,name -o table
  4. Output

    JSON envelope by default; JSON lines, an aligned table or CSV for the rows of data. --fields picks columns with dot paths and --all follows the pages for you.

    shell
    $ dsa teams fixtures 42 --type recent --all -o jsonl
    
    #  -o json    the { data, meta } envelope (default)
    #  -o jsonl   one row of data per line
    #  -o table   aligned columns for reading
    #  -o csv     for spreadsheets
    #  --fields id,home.name   choose columns
    #  --all  --max-pages 5    walk the pages
  5. Watch live

    Business

    Point dsa watch at one or more channels to print frames as JSON lines, or add --state to print the merged fixture after every change. Ticket, reconnect and replay are handled for you.

    shell
    $ dsa watch livescores sport:tennis       # frames as JSON lines
    $ dsa watch fixture:480112 --state        # merged fixture after each change

    Channels, frames and replay rules are in the WebSocket guide. Without a Business key the stream answers 403 ws_not_available.

  6. Scripting and options

    Errors go to stderr with the API's status and code, and the command exits non-zero, so shell scripts can stop on them. The same retry rule as the SDKs applies; --base-url or DATASPORTSAPI_BASE_URL points the CLI elsewhere.

    shell
    $ dsa fixtures win-probability 480112 || echo "no access on this plan"
    
    # options on every command
    #  --api-key dsa_live_…       instead of the keychain
    #  --base-url https://api.datasportsapi.com
    #  --timeout 30s  --max-retries 2

    Base URL resolution: the option or flag first, then DATASPORTSAPI_BASE_URL, then https://api.datasportsapi.com.

From the endpoint pages

Every endpoint shows its command.

All endpoints

Other clients

Your key is one form away.

1,000 free requests a day during the beta. No card, no sales call.