Motivic API
Documentation
Try It Out
Interact with the API from the command line using cURL and jq. Generate a random melody, convert it to a WAV file, and listen to the results.
- 
                                        Make a request to the random melody endpoint and write the response to a JSON file. with default settings... curl -X POST \-H "Content-Type: application/json" \-H "Cache-Control: no-cache" \-d '{}' "https://motivic.io/api/melody/random" > my-motif.json...or with explicit custom user parameters curl -X POST \-H "Content-Type: application/json" \-H "Cache-Control: no-cache" \-d '{ "key":"f#", "mode":"mixolydian", "octave": { "low": 3, "high": 5 }, "leap": { "min": 1, "max": 24 }, "tempo": { "type": "bpm", "units": 140 }, "duration": { "min": 1, "max": 4 }, "length": { "type": "measures", "units": 1 }}' "https://motivic.io/api/melody/random" > my-motif.json
- 
                                        Parse the response to get the motif and save it to a variable MOTIF=$(jq '.response' my-motif.json)
- 
                                        Format the convertor API request body and save it to a variable BODY='{"voice": "sawtooth", "motif": '$MOTIF'}'
- 
                                        Send a request to the Golang convertor endpoint to generate a WAV audio file from the JSON motif. The response will be compressed in a .zip file. curl -X POST \-H "Accept: */*" \-H "Accept-Encoding: gzip, deflate, br" \-H "Content-Type: application/json" \-H "Cache-Control: no-cache" \-d "$BODY" "https://motivic.io/api/convertor" --output my-motif.zip
- 
                                        Unzip the file (MacOS) unzip my-motif.zip
- 
                                        Check your system volume. Make sure it is set to a healthy listening level! 
- 
                                        Play the WAV file (MacOS) afplay my-motif.wav