← anantarultimate.com
For developers

Build for Infinity Core

Infinity Core API — v1 (preview)

Add to Infinity Core from a program on your network or a web address. Infinity Core never runs your code: it talks to it, and its owner turns each one on.

1

Control it

Your program calls Infinity Core and gets its eventsYour programon your networkInfinity Corecallsevents

A program that sees what plays and controls it: Home Assistant, a Stream Deck, a scrobbler, a display on the wall.

uses: read · control · library · sound

Example: Infinity Core for Home Assistant

2

Give it more

Infinity Core asks your program and gets an answerInfinity CoreYour programon your networkasksanswers

A program Infinity Core asks: lyrics, album and artist information, covers, radio stations, items in its ⋯ menus, your amp's volume and input.

provides: lyrics · album_info · artist_info · cover · radio · actions · volume_control

Example: lyrics-from-folder

3

A web source

Infinity Core sends a GET to your address and reads JSON backInfinity Coreyour-site.orghttpsGETJSON

Nothing to run at home: an https address that answers a few plain GETs with JSON. People add it by its address.

gives: lyrics · album_info · artist_info · cover · radio

Example: SPEC §8

One program can do 1 and 2 at once. Messages are JSON-RPC 2.0 over a WebSocket on the home network; no audio goes through this API.

How it connects

  1. Start iton a NAS, a Pi, a computer or Docker
  2. It waitsin Settings › Extensions
  3. The owner enables itand picks what it may do
  4. It workswith a token it keeps

Quick start

pip install infinity-core-api

import asyncio, infinity_core_api as ica
ext = ica.Extension(id="org.example.hello", name="Hello",
                    version="1.0.0", publisher="you", uses=["read"])

@ext.on_ready
async def ready(grant):
    print((await ext.call("zones.list"))["zones"])

asyncio.run(ext.run(host="living-room.local"))
Getting startedPython SDKJavaScript SDKExamplesHome AssistantDiscord

Reference

The full specification follows. It is also on GitHub, with its JSON schema and changelog.

Preview. Until a stable Infinity Core carries this API, breaking changes can still happen; they are announced in CHANGELOG.md and on Discord. The website's API page is built from this file. Licence of this specification, its schemas, SDKs and examples: MIT.

1. What this is

Infinity Core plays a music library and streaming services to the computer's outputs, DAPs over Infinity Link, and network players. The Infinity Core API lets other programs work with it in two ways:

Infinity Core never loads your code. It runs nothing for you and starts nothing.

2. Connecting (extensions)

2.1 Finding Infinity Core

Infinity Core announces itself with DNS-SD as _infinity-core._tcp.local. Its TXT record holds:

keyvalue
v1
idthe Core's id, stable across restarts and updates
pinbase64 SHA-256 of the Core's public key (DER SubjectPublicKeyInfo)
api1 when this Core speaks Infinity Core API v1 (no key = no API)

An extension may also be given an address by hand. GET https://<host>:<port>/lan/hello answers {"v":1,"id":…,"name":…,"pin":…,"api":1} without a token (no api = no API).

2.2 The connection

3. Hello and Enable

3.1 hello (extension → Core, first message)

{"jsonrpc":"2.0","id":1,"method":"hello","params":{
  "api": 1,
  "id": "org.example.lyrics-plus",
  "name": "Lyrics Plus",
  "version": "1.2.0",
  "publisher": "lyric-tools",
  "homepage": "https://github.com/lyric-tools/lyrics-plus",
  "description": "Synced lyrics for K-pop and J-pop releases.",
  "uses": ["read"],
  "provides": ["lyrics"],
  "token": "…"            // omitted the first time
}}

3.2 The answer

{"jsonrpc":"2.0","id":1,"result":{
  "state": "enabled",
  "token": "…",                      // only when a new token was made: store it
  "grant": {"scopes": ["read"], "actsAs": {"profile": 2, "name": "Anna"}},
  "core": {"id": "…", "name": "Living room", "version": "14.1", "api": 1, "preview": true}
}}

state is one of:

statemeaningwhat to do
enabledyou may work; grant says what you may docarry on
waitingthe owner has not enabled you yet (or you asked for more than before)stay connected; extension.state arrives when they decide
disabledswitched off by the ownerthe socket closes; try again later, quietly
blockedblocked for everyone (see reason)stop
upgradethis Core is older than your apitell the person to update Infinity Core

3.3 extension.state (Core → extension, notification)

Sent when the owner enables, changes, disables or removes you: {"state": …, "token"?: …, "grant"?: …}. After disabled or removed Infinity Core closes the socket. After removed your token is gone: drop it and start again with a hello without one.

4. Scopes

scopewhat the person is toldmethods
readSee what <profile> plays, has played and the libraryzones.* reads, outputs.list, queue.get, library.* reads, image.url, history.get, favorites.get, later.get, events.subscribe
controlPlay, pause, skip, change volume and the queue, move music to another outputtransport.*, volume.*, play, queue.* changes, zone.* changes
libraryChange favourites, Later and playlistsfavorites.set, later.*, playlist.* except delete
library.manageDelete playlists, clear History and hide albums (its own tick box, off unless ticked)playlist.delete, history.clear, album.hide, album.unhide
soundSwitch Infinity DSP stages and EQ presetsdsp.*, eq.*

Never available to any extension: music files and folders, tag editing, scans, Settings, accounts and keys, Sync to DAP, updates, Remote access, profiles, logs.

5. Methods (extension → Core)

All ids are opaque strings: keep them and give them back. They are never file paths. Today a track is t:<n> (or tidal:<n> / qobuz:<n>), an album a:<n>, an artist ar:<name>, a playlist p:<n>, a genre g:<name>, a zone z<profile> — but read them as opaque. An "everyone" extension must pass zone wherever a method changes something. A profile extension may leave zone out to mean its profile's current zone.

5.1 Core

methodparamsresult
core.info—{id, name, version, api, preview, profiles?}; profiles lists {id, name} for "everyone" extensions only
events.subscribe{events: [Event…]}the current state of each (§6), then events as they happen
events.unsubscribe{events: [Event…]}{}

5.2 Zones, outputs, queue (read)

methodparamsresult
zones.list—{zones: [Zone]}
zone.get{zone}Zone
outputs.list—{outputs: [Output]}
queue.get{zone, from?: 0, count?: 100}{total, from, items: [Track]}

5.3 Library (read)

methodparamsresult
library.albums{filter?, sort?: "name"|"artist"|"added"|"year", from?, count?: 100}{total, items: [Album]}
library.artists{filter?, sort?, from?, count?}{total, items: [Artist]}
library.genres{from?, count?}{total, items: [{id, name, albums}]}
library.playlists{from?, count?}{total, items: [Playlist]}
library.album{album}Album + {tracks: [Track]}
library.artist{artist}Artist + {albums: [Album]}
library.playlist{playlist, from?, count?}Playlist + {total, items: [Track]}
library.track{track}Track
library.search{query, kinds?: ["track","album","artist","playlist"], count?: 20}{tracks, albums, artists, playlists}
image.url{image, size?: 600}{url, expires}: an https address on the Core, valid 10 minutes, no token needed
history.get{from?, count?: 100}{total, items: [{track: Track, at}]}; private plays left out
favorites.get{kind?: "track"|"album"|"artist", from?, count?}{total, items: [Track|Album|Artist]}
later.get{from?, count?}{total, items: [{id, kind, title?, artist?, added}]}: id is for later.remove

filter is free text matched like the library's own filter box.

5.4 Playback (control)

methodparamsresult
transport.control{zone?, action: "play"|"pause"|"playpause"|"stop"|"next"|"previous"}{}
transport.seek{zone?, position} (seconds) or {zone?, by} (± seconds){}
volume.set{zone?, value} or {zone?, by}: the zone's output, in its own unit (§5.7)Volume
volume.mute{zone?, mute: true|false}Volume
play{zone?, items: [id…], mode?: "now"|"next"|"later", shuffle?: false}; items = track ids, or one album or playlist id{}
queue.play{zone?, position}: play from that place in the queue{}
queue.move{zone?, from, to} (positions){}
queue.remove{zone?, positions: [n…]}{}
queue.clear{zone?}: what is still to come{}
zone.shuffle{zone?, on}{}
zone.repeat{zone?, mode: "off"|"all"|"one"}{}
zone.transfer{zone?, to: output}: the music goes on from the same place on another output or DAPZone
zone.sleep{zone?, minutes} (0 = off){}

5.5 Library changes (library, library.manage)

methodscopeparams
favorites.setlibrary{item, favorite: true|false}
later.add / later.removelibrary{item}: a track, album, artist (ar:), playlist or genre id; later.remove also takes a later.get id
playlist.createlibrary{name, items?: [id…]} → Playlist
playlist.renamelibrary{playlist, name}
playlist.addlibrary{playlist, items: [id…], at?}
playlist.removelibrary{playlist, positions: [n…]}
playlist.reorderlibrary{playlist, from, to}
playlist.deletelibrary.manage{playlist}: removes its .m3u file too
history.clearlibrary.manage{}
album.hide / album.unhidelibrary.manage{album}

5.6 Sound (sound)

methodparamsresult
dsp.get{zone?}{stages: [{id, name, on}]}
dsp.set{zone?, stage: "invert"|"vinyl"|"tube"|"chassis"|"crossfeed", on}the same as dsp.get
eq.get{zone?}{graphic: {on, preset, presets: [name]}, peq: {on, profile, profiles: [name]}}
eq.set{zone?, graphic?: {on?, preset?}, peq?: {on?, profile?}}the same as eq.get

Switching only: presets and stages are made and tuned in Infinity Core.

5.7 Objects

Zone     {id, name, profile: {id, name}, state: "playing"|"paused"|"stopped"|"loading",
          output: Output, nowPlaying?: NowPlaying, queue: {total, position},
          shuffle: bool, repeat: "off"|"all"|"one", private: bool}
NowPlaying {track: Track, position, at, playing}   // position in s at the Core's clock `at` (ms since epoch)
Output   {id, name, kind: "computer"|"dap"|"upnp"|"cast"|"airplay"|"extension", volume?: Volume, inUse?: {profile}}
Volume   {value, min, max, step, unit: "dB"|"percent"|"steps", muted, fixed}   // fixed: line out, no control
Track    {id, title, artists: [string], album?: {id, title}, albumArtist?, disc?, number?, duration,
          source: "library"|"tidal"|"qobuz"|"radio"|…, quality?: {format, sampleRate, bitDepth}, image?}
Album    {id, title, artist, year?, tracks?, source, image?}
Artist   {id, name, image?}
Playlist {id, name, tracks, image?, editable}

Fields may be added in any version: ignore what you do not know. image is an image id for image.url.

6. Events (Core → extension, notifications)

Subscribe with events.subscribe. You receive only what you subscribed to.

eventparamssent when
zone.changed{zone: Zone}state, track, output, volume, shuffle / repeat changes; play, pause or seek
zone.removed{zone: "<id>"}a zone goes away (its profile was removed)
queue.changed{zone, total, position}the queue changes (fetch it with queue.get)
outputs.changed{outputs: [Output]}an output appears, goes or changes
library.changed{}the library changed (fetch what you need)

7. Services you provide (Core → extension)

Declare them in hello.provides. Infinity Core calls them only after you are enabled, and only when they are needed. Answer null when you have nothing: that is not an error. Infinity Core waits 5 s for lyrics, 9 s for searches and 12 s for anything else, then goes on without you. It also asks no more than 2 requests a second.

7.1 lyrics

lyrics.get {title, artist, album?, duration} → {synced?: "[mm:ss.xx] line\n…", plain?: "…", instrumental?: true} or null

7.2 album_info

7.3 artist_info

artist.get {name, mbid?} → {name, bio?: {text, url?, lang}, image?: url, members?: [{name, from?, to?}], born?, formed?, links?: [{label, url}]} or null

7.4 cover

cover.search {album, artist?} → {results: [{url, width, height, label?}]}

7.5 track_identify (reserved)

Not used by Infinity Core yet: the name and shape are kept for a later version. Until then Infinity Core ignores it.

track.identify {fingerprint, duration} → {results: [{score, title, artist, album?, albumId?}]}

7.6 actions

7.7 volume_control

7.8 source_control

7.11 radio

radio.search {query?, tag?, country?} → {stations: [{id, name, url, logo?, country?, tags?, codec?, bitrate?, homepage?}]}

7.9 status

status.set (ext → Core, notification) {message, error?: false}: one line in your row in Settings (≤ 80 characters).

7.10 settings

8. Web sources

A web source answers plain https GETs. People add it by its address in Settings › Extensions › Add web source.

GETanswer
{address}/infinity-extension.json{api: 1, id, name, version, publisher, homepage?, description?, provides: ["lyrics"|"album_info"|"artist_info"|"cover"|"radio"]}
{address}/lyrics?title=&artist=&album=&duration=as §7.1
{address}/album/search?album=&artist=&tracks=as §7.2
{address}/album/{id}as §7.2
{address}/artist?name=&mbid=as §7.3
{address}/cover/search?album=&artist=as §7.4
{address}/radio/search?query=&tag=&country=as §7.11

9. Errors

Standard JSON-RPC codes plus:

codemeaning
-32001not enabled (yet)
-32003not allowed: outside your grant, or a zone of another profile
-32004not found (an id that no longer exists)
-32009that output is in use by another profile
-32010not possible on this output (e.g. a fixed volume)
-32029too many requests: slow down (bursts of 100, then 20 a second on average)

10. Rules for extensions

11. Versions