Skip to main content

API4 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

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

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) Find objects with an 'add' date newer than the specified dateYES
'update'set_filterISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified dateYES
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES
'include'stringalbums, songs (include child objects in the response)YES

Example

album

This returns a single album based on the UID provided

InputTypeDescriptionOptional
'filter'integerUID of Album, returns album JSONNO
'include'stringsongs (include child objects in the response)YES

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

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) Find objects with an 'add' date newer than the specified dateYES
'update'set_filterISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified dateYES
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES
'include'stringalbums, songs (include child objects in the response)YES

Example

artist

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

InputTypeDescriptionOptional
'filter'integerUID of Artist, returns artist JSONNO
'include'stringalbums, songs (include child objects in the response)YES

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

catalogs

  • NEW in 4.2.0

This searches the catalogs and returns... catalogs

InputTypeDescriptionOptional
'filter'stringmusic, clip, tvshow, movie, personal_video, podcast (Catalog type)YES

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'stringadd_to_catalog, clean_catalogNO
'catalog'integer$catalog_idNO

Example: clean_catalog

Example: add_to_catalog

Example: error

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'stringadd, clean, verify, removeNO
'catalog'integer$catalog_idNO

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'stringsong, album, artist, playlist, podcast, podcast_episode, video, tvshow, tvshow_seasonNO
'id'integer$object_idNO
'flag'boolean0, 1NO

Example

followers

This gets a user's followers

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

Example

following

This get the user list followed by a user

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

Example

friends_timeline

This get current user friends timeline

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

Example

get_indexes

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

InputTypeDescriptionOptional
'type'stringsong, album, artist, playlistNO
'filter'stringYES
'add'set_filterISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified dateYES
'update'set_filterISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified dateYES
'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 result)YES

SONGS

Example

ARTIST

Example

ALBUM

Example

PLAYLIST

Example

get_similar

  • NEW in 4.2.0

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

InputTypeDescriptionOptional
'type'stringsong, artistNO
'filter'integerartist id or song idNO
'offset'integerReturn results starting from this index positionYES
'limit'integerMaximum number of results to returnYES

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

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

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) Find objects with an 'add' date newer than the specified dateYES
'update'set_filterISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified dateYES
'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 result)YES
'show_dupes'integer0, 1 (if true if true ignore 'api_hide_dupe_searches' setting)YES

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'stringpublic, private (Playlist type)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'stringpublic, private (Playlist type)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'stringrecent, forgotten, unplayed, random (default = 'random')YES
'filter'stringstring LIKE matched to song titleYES
'album'integer$album_idYES
'artist'integer$artist_idYES
'flag'integer0, 1 (get flagged songs only. default = 0)YES
'format'stringsong, 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

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'stringepisodes (include podcast_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'stringepisodes (include podcast_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

rate

This rates a library item

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

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

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

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

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) Find objects with an 'add' date newer than the specified dateYES
'update'set_filterISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified dateYES
'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

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'stringsong, album, artistNO
'filter'stringnewest, highest, frequent, recent, forgotten, flagged, randomNO
'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

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

timeline

This gets a user's timeline

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

Example

toggle_follow

This follow/unfollow a user

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

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'stringsong, podcastNO
'overwrite'boolean0, 1YES

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_from_tags

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

InputTypeDescriptionOptional
'type'stringsong, artist, albumNO
'id'integer$artist_id, $album_id, $song_idNO

Example

update_podcast

Sync and download new podcast episodes

InputTypeDescriptionOptional
'id'integer$object_idNO

Example

user

This gets a user's 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'stringe.g. user@gmail.comNO
'fullname'stringYES
'disable'boolean0, 1YES

Example

user_update

Update an existing user.

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

Example

user_delete

Delete an existing user.

InputTypeDescriptionOptional
'username'stringNO

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

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'stringsong, podcastNO
'bitrate'integermax bitrate for transcoding in bytes (e.g 192000=192Kb)YES
'format'stringmp3, ogg, raw, etc (raw returns the original format)YES
'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'stringsong, podcastNO
'format'stringmp3, ogg, raw, etc (raw returns the original format)YES

get_art

Get an art image.

InputTypeDescriptionOptional
'id'integer$object_idNO
'type'stringsong, artist, album, playlist, search, podcastNO

Control Methods

localplay

This is for controlling localplay

InputTypeDescriptionOptional
'command'stringnext, prev, stop, play, pause, add, volume_up, volume_down, volume_mute, delete_all, skip, statusNO
'oid'integer$object_idYES
'type'stringsong, video, podcast_episode, channel, broadcast, democratic, live_streamYES
'clear'boolean0, 1 (Clear the current playlist before adding)YES
  • 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>[VOTE COUNT]</vote> 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