API Documentation
myMPD uses a JSON-RPC 2 for the communication between frontend and backend.
JSON-RPC Id
The json-rpc Id is the combination of two numeric ids.
- Client ID: Generated on initial loading of the client, first 6 digits
- Request ID: Incremented on each request, last 3 digits, wraps around
The websocket connection registers the Client ID on the webserver. This registration is used to send async responses from the webserver to a specific client.
Endpoints
API endpoint: /api/<partition>
Notifications from the backend to the frontend are sent over a websocket connection.
Websocket endpoint: /ws/<partition>
Example API calls
Pin protection
If myMPD is protected with a pin some methods require authentication with a special header.
Authenticate
Use the session string in the response for authenticated requests. The session is valid for 30 minutes.
Authenticated request
To send a request with authentication data add a X-myMPD-Session
header to it.
Validate the token
Content-Type: application/json
X-myMPD-Session: <token>
{"jsonrpc":"2.0","id":0,"method":"MYMPD_API_SESSION_VALIDATE","params":{}}