JSON 4.3
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.
| Input | Type | Description | Optional |
|---|---|---|---|
| 'auth' | string | $passphrase (Timestamp . Password SHA hash) OR (API Key) | NO |
| 'user' | string | $username (Required if login/password authentication) | YES |
| 'timestamp' | integer | UNIXTIME() (Timestamp used in seed of password hash. Required if login/password authentication) | YES |
| 'version' | string | $version (API Version that the application understands) | YES |
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
| Input | Type | Description | Optional |
|---|---|---|---|
| 'auth' | string | (Session ID) returns version information and extends the session if passed | YES |
| 'version' | string | $version (API Version that the application understands) | YES |
goodbye
Destroy a session using the auth parameter.
| Input | Type | Description | Optional |
|---|---|---|---|
| 'auth' | string | (Session ID) destroys the session if it exists | NO |
url_to_song
This takes a url and returns the song object in question
| Input | Type | Description | Optional |
|---|---|---|---|
| 'url' | string | Full Ampache URL from server, translates back into a song JSON | NO |
Data Methods
get_indexes
This takes a collection of inputs and returns ID + name for the object type
| Input | Type | Description | Optional |
|---|---|---|---|
| 'type' | string | song, album, artist, playlist | NO |
| 'filter' | string | YES | |
| 'add' | set_filter | ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date | YES |
| 'update' | set_filter | ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date | YES |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
| 'hide_search' | integer | 0, 1 (if true do not include searches/smartlists in the result) | YES |
SONGS
ARTIST
ALBUM
PLAYLIST
advanced_search
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.
Using advanced_search
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
ARTIST
ALBUM
artists
This takes a collection of inputs and returns artist objects.
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | Value is Alpha Match for returned results, may be more than one letter/number | YES |
| 'exact' | boolean | if true filter is exact rather then fuzzy | YES |
| 'add' | set_filter | ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date | YES |
| 'update' | set_filter | ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date | YES |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
| 'include' | string | albums, songs (include child objects in the response) | YES |
artist
This returns a single artist based on the UID of said artist
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | integer | UID of Artist, returns artist JSON | NO |
| 'include' | string | albums, songs (include child objects in the response) | YES |
artist_albums
This returns the albums of an artist
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | integer | UID of Artist, returns Album JSON | NO |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
artist_songs
This returns the songs of the specified artist
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | integer | UID of Artist, returns Song JSON | NO |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
albums
This returns albums based on the provided search filters
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | Value is Alpha Match for returned results, may be more than one letter/number | YES |
| 'exact' | boolean | if true filter is exact rather then fuzzy | NO |
| 'add' | set_filter | ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date | YES |
| 'update' | set_filter | ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date | YES |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
| 'include' | string | albums, songs (include child objects in the response) | YES |
album
This returns a single album based on the UID provided
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | integer | UID of Album, returns album JSON | NO |
| 'include' | string songs (include child objects in the response) | YES |
album_songs
This returns the songs of a specified album
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | integer | UID of Album, returns song JSON | NO |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
tags
This returns the tags (Genres) based on the specified filter
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | Value is Alpha Match for returned results, may be more than one letter/number | YES |
| 'exact' | boolean | if true filter is exact rather then fuzzy | YES |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
tag
This returns a single tag based on UID
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | integer | UID of tag, returns tag JSON | NO |
tag_artists
This returns the artists associated with the tag in question as defined by the UID
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | integer | UID of tag, returns artist JSON | NO |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
tag_albums
This returns the albums associated with the tag in question
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | integer | UID of tag, returns album JSON | NO |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
tag_songs
returns the songs for this tag
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | integer | UID of tag, returns song JSON | NO |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
songs
Returns songs based on the specified filter
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | Value is Alpha Match for returned results, may be more than one letter/number | NO |
| 'add' | set_filter | ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date | YES |
| 'update' | set_filter | ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date | YES |
| 'exact' | boolean | if true filter is exact rather then fuzzy | NO |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
song
returns a single song
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | integer | UID of Song, returns song JSON | NO |
playlists
This returns playlists based on the specified filter
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | Value is Alpha Match for returned results, may be more than one letter/number | YES |
| 'exact' | boolean | if true filter is exact rather then fuzzy | YES |
| 'add' | set_filter | ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date | YES |
| 'update' | set_filter | ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date | YES |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
| 'hide_search' | integer | 0, 1 (if true do not include searches/smartlists in the result) | YES |
playlist
This returns a single playlist
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | UID of playlist, returns playlist JSON | NO |
playlist_songs
This returns the songs for a playlist
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | UID of Playlist, returns song JSON | NO |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
playlist_create
This create a new playlist and return it
| Input | Type | Description | Optional |
|---|---|---|---|
| 'name' | string | Playlist name | NO |
| 'type' | string | public, private (Playlist type) | YES |
playlist_edit
This modifies name and type of a playlist Previously name and type were mandatory while filter wasn't. this has been reversed.
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | UID of Playlist | NO |
| 'name' | string | Playlist name | YES |
| 'type' | string | public, private (Playlist type) | YES |
| 'items' | string | comma-separated song_id's (replace existing items with a new object_id) | YES |
| 'tracks' | string | comma-separated playlisttrack numbers matched to items in order | YES |
playlist_delete
This deletes a playlist
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | UID of Playlist | NO |
playlist_add_song
This adds a song to a playlist. setting check=1 will not add duplicates to the playlist
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | integer | UID of Playlist | NO |
| 'song' | integer | UID of song to add to playlist | NO |
| 'check' | boolean | 0, 1 Whether to check and ignore duplicates (default = 0) | YES |
playlist_remove_song
This remove a song from a playlist. Previous versions required 'track' instead of 'song'.
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | UID of Playlist | NO |
| 'song' | integer | UID of song to remove from playlist | YES |
| 'track' | integer | Track number to remove from playlist | YES |
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
| Input | Type | Description | Optional |
|---|---|---|---|
| 'mode' | string | recent, forgotten, unplayed, random (default = 'random') | YES |
| 'filter' | string | string LIKE matched to song title | YES |
| 'album' | integer | $album_id | YES |
| 'artist' | integer | $artist_id | YES |
| 'flag' | integer | 0, 1 (get flagged songs only. default = 0) | YES |
| 'format' | string | song, index, id (default = 'song') | YES |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
SONG
INDEX
ID
shares
- NEW in 4.2.0
This searches the shares and returns... shares
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | Value is Alpha Match for Share Title | YES |
| 'exact' | integer | 0, 1 boolean to match the exact filter string | YES |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
share
- (MINIMUM_API_VERSION=420000)
Return shares by UID
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | integer | UID of Share, returns song JSON NO | NO |
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.
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | UID of object you are sharing | NO |
| 'type' | string | object_type | NO |
| 'description' | string | description (will be filled for you if empty) | YES |
| 'expires' | integer | days to keep active | YES |
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.
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | Alpha-numeric search term | NO |
| 'stream' | boolean | 0, 1 | YES |
| 'download' | boolean | 0, 1 | YES |
| 'expires' | integer | number of whole days before expiry | YES |
| 'description' | string | update description | YES |
share_delete
- (MINIMUM_API_VERSION=420000
Delete an existing share.
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | integer | UID of Share to delete | NO |
get_similar
- NEW in 4.2.0
Return similar artist id's or similar song ids compared to the input filter
| Input | Type | Description | Optional |
|---|---|---|---|
| 'type' | string | song, artist | NO |
| 'filter' | integer | artist id or song id | NO |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
search_songs
This searches the songs and returns... songs
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | Value is Alpha Match for Song Title, Artist Name, Album Name, Genre Name returns song JSON | NO |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
videos
This returns video objects!
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | Value is Alpha Match for returned results, may be more than one letter/number | NO |
| 'exact' | boolean | if true filter is exact rather then fuzzy | YES |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
video
This returns a single video
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | integer | UID of video, returns video JSON | NO |
podcasts
- NEW in 4.2.0
Get information about podcasts
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | Value is Alpha Match for returned results, may be more than one letter/number | YES |
| 'offset' | integer | Return results starting from this index position | YES |
| 'limit' | integer | Maximum number of results to return | YES |
| 'include' | string | episodes (include podcast_episodes in the response) | YES |
podcast
- NEW in 4.2.0
Get the podcast from it's id.
| Input | Type | Description | Optional |
|---|---|---|---|
| 'filter' | string | UID of podcast, returns podcast JSON | NO |
| 'include' | string | episodes (include podcast_episodes in the response) | YES |
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.
| Input | Type | Description | Optional |
|---|---|---|---|
| 'url' | string | rss url for podcast | NO |
| 'catalog' | string | podcast catalog | NO |