API 4 JSON

Lets go through come calls and examples that you can do for each JSON method.

Remember that Binary data methods will not return JSON; just the file/data you have requested.

Non-Data Methods

handshake

This is the function that handles verifying a new handshake Takes a timestamp, auth key, and username.

InputTypeDescriptionOptional
'auth'string$passphrase (Timestamp . Password SHA hash) OR (API Key)NO
'user'string$username (Required if login/password authentication)YES
'timestamp'integerUNIXTIME() (Timestamp used in seed of password hash. Required if login/password authentication)YES
'version'string$version (API Version that the application understands)YES

Example

ping

This can be called without being authenticated, it is useful for determining if what the status of the server is, and what version it is running/compatible with

InputTypeDescriptionOptional
'auth'string(Session ID) returns version information and extends the session if passedYES
'version'string$version (API Version that the application understands)YES

Example

goodbye

Destroy a session using the auth parameter.

InputTypeDescriptionOptional
'auth'string(Session ID) destroys the session if it existsNO

Example

url_to_song

This takes a url and returns the song object in question

InputTypeDescriptionOptional
'url'stringFull Ampache URL from server, translates back into a song JSONNO

Example

Data Methods

get_indexes

This takes a collection of inputs and returns ID + name for the object type

InputTypeDescriptionOptional
'type'string'song', 'album', 'artist', 'playlist'NO
'filter'stringYES
'add'set_filterISO 8601 Date Format (2020-09-16)YES
Find objects with an 'add' date newer than the specified date
'update'set_filterISO 8601 Date Format (2020-09-16)YES
Find objects with an 'update' time newer than the specified date
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES
'hide_search'integer0,1, if true do not include searches/smartlists in the resultYES

SONGS

Example

ARTIST

Example

ALBUM

Example

PLAYLIST

Example

Changes to text searches

  • 'is not' has been added shifting values down the list. 0=contains, 1=does not contain, 2=starts with, 3=ends with 4=is, 5=is not, 6=sounds like, 7=does not sound like
  • rule_1['name'] is depreciated. Instead of rule_1['name'] use rule_1['title'] (I have put a temp workaround into the search rules to alleviate this change for any existing apps)
  • Metadata Search is combined with text and numeric. Meaning that changes to text lists push the numeric fields down.

Perform an advanced search given passed rules. This works in a similar way to the web/UI search pages. You can pass multiple rules as well as joins to create in depth search results

Rules must be sent in groups of 3 using an int (starting from 1) to designate which rules are combined. Use operator ('and'|'or') to choose whether to join or separate each rule when searching.

Refer to the Advanced Search page for details about creating searches.

  • INPUTS
    • ampache_url = (string)
    • ampache_API = (string)
    • operator = (string) 'and'|'or' (whether to match one rule or all)
    • rules = (array) = [[rule_1,rule_1_operator,rule_1_input], [rule_2,rule_2_operator,rule_2_input], [etc]]
    • type = (string) 'song', 'album', 'artist', 'playlist', 'label', 'user', 'video'
    • random = (integer) 0|1 (random order of results; default to 0)
    • offset = (integer)
    • limit' = (integer)

SONG

Example

ARTIST

Example

ALBUM

Example

artists

This takes a collection of inputs and returns artist objects.

InputTypeDescriptionOptional
'filter'stringValue is Alpha Match for returned results, may be more than one letter/numberYES
'exact'booleanif true filter is exact rather then fuzzyYES
'add'set_filterISO 8601 Date Format (2020-09-16)YES
Find objects with an 'add' date newer than the specified date
'update'set_filterISO 8601 Date Format (2020-09-16)YES
Find objects with an 'update' time newer than the specified date
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES
'include'string'albums', 'songs' and will include the corresponding JSONYES

Example

artist

This returns a single artist based on the UID of said artist

InputTypeDescriptionOptional
'filter'integerUID of Artist, returns artist JSONNO
'include'string'albums', 'songs' and will include the corresponding JSON nested in the artist JSONYES

Example

artist_albums

This returns the albums of an artist

InputTypeDescriptionOptional
'filter'integerUID of Artist, returns Album JSONNO
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

artist_songs

This returns the songs of the specified artist

InputTypeDescriptionOptional
'filter'integerUID of Artist, returns Song JSONNO
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

albums

This returns albums based on the provided search filters

InputTypeDescriptionOptional
'filter'stringValue is Alpha Match for returned results, may be more than one letter/numberYES
'exact'booleanif true filter is exact rather then fuzzyNO
'add'set_filterISO 8601 Date Format (2020-09-16)YES
Find objects with an 'add' date newer than the specified date
'update'set_filterISO 8601 Date Format (2020-09-16)YES
Find objects with an 'update' time newer than the specified date
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES
'include'string'albums', 'songs' will include nested in the album JSONYES

Example

album

This returns a single album based on the UID provided

InputTypeDescriptionOptional
'filter'integerUID of Album, returns album JSONNO
'include'string'songs' will include the corresponding JSON nested in the album JSONYES

Example

album_songs

This returns the songs of a specified album

InputTypeDescriptionOptional
'filter'integerUID of Album, returns song JSONNO
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

tags

This returns the tags (Genres) based on the specified filter

InputTypeDescriptionOptional
'filter'stringValue is Alpha Match for returned results, may be more than one letter/numberYES
'exact'booleanif true filter is exact rather then fuzzyYES
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

tag

This returns a single tag based on UID

InputTypeDescriptionOptional
'filter'integerUID of tag, returns tag JSONNO

Example

tag_artists

This returns the artists associated with the tag in question as defined by the UID

InputTypeDescriptionOptional
'filter'integerUID of tag, returns artist JSONNO
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

tag_albums

This returns the albums associated with the tag in question

InputTypeDescriptionOptional
'filter'integerUID of tag, returns album JSONNO
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

tag_songs

returns the songs for this tag

InputTypeDescriptionOptional
'filter'integerUID of tag, returns song JSONNO
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

songs

Returns songs based on the specified filter

InputTypeDescriptionOptional
'filter'stringValue is Alpha Match for returned results, may be more than one letter/numberNO
'add'set_filterISO 8601 Date Format (2020-09-16)YES
Find objects with an 'add' date newer than the specified date
'update'set_filterISO 8601 Date Format (2020-09-16)YES
Find objects with an 'update' time newer than the specified date
'exact'booleanif true filter is exact rather then fuzzyNO
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

song

returns a single song

InputTypeDescriptionOptional
'filter'integerUID of Song, returns song JSONNO

Example

playlists

This returns playlists based on the specified filter

InputTypeDescriptionOptional
'filter'stringValue is Alpha Match for returned results, may be more than one letter/numberYES
'exact'booleanif true filter is exact rather then fuzzyYES
'add'set_filterISO 8601 Date Format (2020-09-16)YES
Find objects with an 'add' date newer than the specified date
'update'set_filterISO 8601 Date Format (2020-09-16)YES
Find objects with an 'update' time newer than the specified date
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES
'hide_search'integer0,1, if true do not include searches/smartlists in the resultYES

Example

playlist

This returns a single playlist

InputTypeDescriptionOptional
'filter'stringUID of playlist, returns playlist JSONNO

Example

playlist_songs

This returns the songs for a playlist

InputTypeDescriptionOptional
'filter'stringUID of Playlist, returns song JSONNO
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

playlist_create

This create a new playlist and return it

InputTypeDescriptionOptional
'name'stringPlaylist nameNO
'type'stringPlaylist type 'public', 'private'YES

Example

playlist_edit

This modifies name and type of a playlist Previously name and type were mandatory while filter wasn't. this has been reversed.

InputTypeDescriptionOptional
'filter'stringUID of PlaylistNO
'name'stringPlaylist nameYES
'type'stringPlaylist type 'public', 'private'YES
'items'stringcomma-separated song_id's (replace existing items with a new object_id)YES
'tracks'stringcomma-separated playlisttrack numbers matched to items in orderYES

Example

playlist_delete

This deletes a playlist

InputTypeDescriptionOptional
'filter'stringUID of PlaylistNO

Example

playlist_add_song

This adds a song to a playlist. setting check=1 will not add duplicates to the playlist

InputTypeDescriptionOptional
'filter'integerUID of PlaylistNO
'song'integerUID of song to add to playlistNO
'check'boolean0, 1 Whether to check and ignore duplicates (default = 0)YES

Example

playlist_remove_song

This remove a song from a playlist. Previous versions required 'track' instead of 'song'.

InputTypeDescriptionOptional
'filter'stringUID of PlaylistNO
'song'integerUID of song to remove from playlistYES
'track'integerTrack number to remove from playlistYES

Example

playlist_generate

Get a list of song JSON, indexes or id's based on some simple search criteria 'recent' will search for tracks played after 'Popular Threshold' days 'forgotten' will search for tracks played before 'Popular Threshold' days 'unplayed' added in 400002 for searching unplayed tracks

InputTypeDescriptionOptional
'mode'string'recent', 'forgotten', 'unplayed', 'random' (default = 'random')YES
'filter'stringstring LIKE matched to song titleYES
'album'integer$album_idYES
'artist'integer$artist_idYES
'flag'integerget flagged songs only 0, 1 (default = 0)YES
'format'string'song', 'index','id' (default = 'song')YES
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

SONG

Example

INDEX

Example

ID

Example

shares

  • NEW in 4.2.0

This searches the shares and returns... shares

InputTypeDescriptionOptional
'filter'stringValue is Alpha Match for Share TitleYES
'exact'integer0, 1 boolean to match the exact filter stringYES
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

share

  • (MINIMUM_API_VERSION=420000)

Return shares by UID

InputTypeDescriptionOptional
'filter'integerUID of Share, returns song JSON NONO

Example

share_create

  • (MINIMUM_API_VERSION=420000

Create a public url that can be used by anyone to stream media. Takes the file id with optional description and expires parameters.

InputTypeDescriptionOptional
'filter'stringUID of object you are sharingNO
'type'stringobject_typeNO
'description'stringdescription (will be filled for you if empty)YES
'expires'integerdays to keep activeYES

Example

share_edit

  • (MINIMUM_API_VERSION=420000

Update the description and/or expiration date for an existing share. Takes the share id to update with optional description and expires parameters.

InputTypeDescriptionOptional
'filter'stringAlpha-numeric search termNO
'stream'boolean0, 1YES
'download'boolean0, 1YES
'expires'integernumber of whole days before expiryYES
'description'stringupdate descriptionYES

Example

share_delete

  • (MINIMUM_API_VERSION=420000

Delete an existing share.

InputTypeDescriptionOptional
'filter'integerUID of Share to deleteNO

Example

get_similar

  • NEW in 4.2.0

Return similar artist id's or similar song ids compared to the input filter

InputTypeDescriptionOptional
'type'string'song' or 'artist'NO
'filter'integerartist id or song idNO
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

search_songs

This searches the songs and returns... songs

InputTypeDescriptionOptional
'filter'stringValue is Alpha Match for Song Title, Artist Name, Album Name, Genre Name returns song JSONNO
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

videos

This returns video objects!

InputTypeDescriptionOptional
'filter'stringValue is Alpha Match for returned results, may be more than one letter/numberNO
'exact'booleanif true filter is exact rather then fuzzyYES
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

video

This returns a single video

InputTypeDescriptionOptional
'filter'integerUID of video, returns video JSONNO

Example

podcasts

  • NEW in 4.2.0

Get information about podcasts

InputTypeDescriptionOptional
'filter'stringValue is Alpha Match for returned results, may be more than one letter/numberYES
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES
'include'string'episodes' (include episodes in the response)YES

Example

podcast

  • NEW in 4.2.0

Get the podcast from it's id.

InputTypeDescriptionOptional
'filter'stringUID of podcast, returns podcast JSONNO
'include'string'episodes' (include episodes in the response)YES

Example

podcast_create

  • NEW in 4.2.0

Create a podcast that can be used by anyone to stream media. Takes the url and catalog parameters.

InputTypeDescriptionOptional
'url'stringrss url for podcastNO
'catalog'stringpodcast catalogNO

Example

podcast_edit

  • NEW in 4.2.0

Update the description and/or expiration date for an existing podcast. Takes the podcast id to update with optional description and expires parameters.

InputTypeDescriptionOptional
'filter'stringAlpha-numeric search termNO
'feed'stringfeed rss xml urlYES
'title'stringtitle stringYES
'website'stringsource website urlYES
'description'stringYES
'generator'stringYES
'copyright'stringYES

Example

podcast_delete

  • NEW in 4.2.0

Delete an existing podcast.

InputTypeDescriptionOptional
'filter'stringUID of podcast to deleteNO

Example

podcast_episodes

  • NEW in 4.2.0

This returns the episodes for a podcast

InputTypeDescriptionOptional
'filter'stringUID of podcastNO
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

podcast_episode

  • NEW in 4.2.0

Get the podcast_episode from it's id.

InputTypeDescriptionOptional
'filter'stringpodcast_episode ID numberNO

Example

podcast_episode_delete

  • NEW in 4.2.0

Delete an existing podcast_episode.

InputTypeDescriptionOptional
'filter'stringUID of podcast_episode to deleteNO

Example

stats

Get some items based on some simple search types and filters. This method has partial backwards compatibility with older api versions but should be updated to follow the current input values. (Changed in 400001 filter added)

InputTypeDescriptionOptional
'type'string'song', 'album', 'artist'NO
'filter'string'newest', 'highest', 'frequent', 'recent', 'forgotten', 'flagged', 'random'NO
'user_id'integerYES
'username'stringYES
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

SONG

Example

ARTIST

Example

ALBUM

Example

user

This get an user public information

InputTypeDescriptionOptional
'username'stringUsername of the user for who to get detailsNO

Example

user_create

Create a new user. (Requires the username, password and email.)

InputTypeDescriptionOptional
'username'string$usernameNO
'password'stringhash('sha256', $password))NO
'email'string'user@gmail.com'NO
'fullname'stringYES
'disable'boolean0, 1YES

Example

user_update

Update an existing user.

InputTypeDescriptionOptional
'username'string$usernameNO
'password'stringhash('sha256', $password))YES
'email'string'user@gmail.com'YES
'fullname'stringYES
'website'stringYES
'state'stringYES
'city'stringYES
'disable'boolean0, 1YES
'maxbitrate'stringYES

Example

user_delete

Delete an existing user.

InputTypeDescriptionOptional
'username'stringNO

Example

licenses

  • NEW in 4.2.0

This returns the licenses based on the specified filter

InputTypeDescriptionOptional
'filter'stringValue is Alpha Match for returned results, may be more than one letter/numberYES
'exact'booleanif true filter is exact rather then fuzzyYES
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

Example

license

  • NEW in 4.2.0

This returns a single license based on UID

InputTypeDescriptionOptional
'filter'integerUID of license, returns license JSONNO

Example

license_songs

  • NEW in 4.2.0

This returns a list of songs based on the filter ID

InputTypeDescriptionOptional
'filter'integerUID of license, returns song JSONNO

Example

followers

This get an user followers

InputTypeDescriptionOptional
'username'stringUsername of the user for who to get followers listNO

Example

following

This get the user list followed by an user

InputTypeDescriptionOptional
'username'string(Username of the user for who to get following listNO

Example

toggle_follow

This follow/unfollow an user

InputTypeDescriptionOptional
'username'stringUsername of the user to follow/unfollowNO

Example

last_shouts

This get the latest posted shouts

InputTypeDescriptionOptional
'username'stringUsername of the user for who to get latest shoutsYES
'limit'integerMaximum number of results to returnYES

Example

rate

This rates a library item

InputTypeDescriptionOptional
'type'string'song', 'album', 'artist', 'playlist',NO
'podcast', 'podcast_episode', 'video'
'tvshow', 'tvshow_season'
'id'integerlibrary item idNO
'rating'integerrating between 0-5NO

Example

flag

This flags a library item as a favorite

  • Setting flag to true (1) will set the flag
  • Setting flag to false (0) will remove the flag
InputTypeDescriptionOptional
'type'string'song', 'album', 'artist', 'playlist',NO
'podcast', 'podcast_episode', 'video'
'tvshow', 'tvshow_season'
'id'integer$object_idNO
'flag'boolean0, 1NO

Example

record_play

Take a song_id and update the object_count and user_activity table with a play. This allows other sources to record play history to ampache

NOTE Ampache 4.3.0

  • 'user' has been made optional
  • 'user' can be the user id (e.g 20) or the username (e.g generic_user)
  • 'date' has also been added as an optional parameter
InputTypeDescriptionOptional
'id'integer$object_idNO
'user'integer,string$user_id OR $usernameYES
'client'string$agentYES
'date'stringUNIXTIME()YES

Example

scrobble

Search for a song using text info and then record a play if found. This allows other sources to record play history to ampache

InputTypeDescriptionOptional
'song'string$song_nameNO
'artist'string$artist_nameNO
'album'string$album_nameNO
'songmbid'string$song_mbidYES
'artistmbid'string$artist_mbidYES
'albummbid'string$album_mbidYES
'date'integerUNIXTIME()YES
'client'string$agentYES

Example

catalogs

  • NEW in 4.2.0

This searches the catalogs and returns... catalogs

InputTypeDescriptionOptional
'filter'stringCatalog type music, clip, tvshow, movie, personal_video, podcastYES

Example

catalog

  • NEW in 4.2.0

Return catalog by UID

InputTypeDescriptionOptional
'filter'integerUID of CatalogNO

Example

catalog_action

Kick off a catalog update or clean for the selected catalog

InputTypeDescriptionOptional
'task'string'add_to_catalog', 'clean_catalog'NO
'catalog'integer$catalog_idNO

Example

catalog_file

  • NEW in 4.2.0

Perform actions on local catalog files. Single file versions of catalog add, clean, verify and remove (delete) Make sure you remember to urlencode those file names!

InputTypeDescriptionOptional
'file'stringFULL path to local fileNO
'task'string'add','clean','verify','remove'NO
'catalog'integer$catalog_idNO

Example

timeline

This get an user timeline

InputTypeDescriptionOptional
'username'stringUsername of the user for whom to get the timelineNO
'limit'integerMaximum number of results to returnYES
'since'integerUNIXTIME()YES

Example

friends_timeline

This get current user friends timeline

InputTypeDescriptionOptional
'limit'integerMaximum number of results to returnYES
'since'integerUNIXTIME()NO

Example

update_from_tags

Update a single album, artist, song from the tag data

InputTypeDescriptionOptional
'type'string'artist', 'album', 'song'NO
'id'integer$artist_id, $album_id, $song_idNO

Example

update_artist_info

Update artist information and fetch similar artists from last.fm Make sure lastfm_API_key is set in your configuration file

InputTypeDescriptionOptional
'id'integer$artist_idNO

Example

update_art

Updates a single album, artist, song running the gather_art process Doesn't overwrite existing art by default.

InputTypeDescriptionOptional
'id'integer$object_idNO
'type'string'song', 'podcast'NO
'overwrite'boolean0, 1YES

Example

update_podcast

Sync and download new podcast episodes

InputTypeDescriptionOptional
'id'integer$object_idNO

Example

Binary Data Methods

stream

Streams a given media file. Takes the file id in parameter with optional max bit rate, file format, time offset, size and estimate content length option.

InputTypeDescriptionOptional
'id'integer$object_idNO
'type'string'song', 'podcast'NO
'bitrate'integermax bitrate for transcodingYES
'format'string'mp3', 'ogg', 'raw', etcYES
'offset'integertime offset in secondsYES
'length'boolean0, 1YES

download

Downloads a given media file. set format=raw to download the full file

InputTypeDescriptionOptional
'id'integer$object_idNO
'type'string'song', 'podcast'NO
'format'string'mp3', 'ogg', 'raw', etcYES

get_art

Get an art image.

InputTypeDescriptionOptional
'id'integer$object_idNO
'type'string'song', 'artist', 'album', 'playlist', 'search', 'podcast'NO

Control Methods

localplay

This is for controlling localplay

InputTypeDescriptionOptional
'command'string'next', 'prev', 'stop', 'play', 'pause', 'add', 'volume_up',NO
'volume_down', 'volume_mute', 'delete_all', 'skip', 'status'
'oid'integerobject_idYES
'type'string'Song', 'Video', 'Podcast_Episode', 'Channel',YES
'Broadcast', 'Democratic', 'Live_Stream'
'clear'boolean0,1 Clear the current playlist before addingYES
  • return object
"localplay": { "command": {} }
  • throws object
"error": ""

Example

Example (status)

democratic

This is for controlling democratic play

  • ACTION
    • method
      • vote
        • oid (Unique ID of the element you want to vote on)
        • type (Type of object, only song is currently accepted so this is optional)
      • devote
        • oid (Unique ID of the element you want to vote on)
        • type (Type of object, only song is currently accepted so this is optional)
      • playlist (Returns an array of song items with an additional \[VOTE COUNT]\ element)
      • play (Returns the URL for playing democratic play)
InputTypeDescriptionOptional
'oid'integerNO
'method'stringNO
'action'stringNO
  • return object|array
"url": ""|"method": "","result": false|"song": []
  • throws object
"error": ""

Example Example Example