feross / bitmidi.com

🎹 Listen to free MIDI songs, download the best MIDI files, and share the best MIDIs on the web
https://bitmidi.com
572 stars 52 forks source link

API support to submit MIDI files #119

Open mtagstyle opened 2 years ago

mtagstyle commented 2 years ago

I'm not sure how "curated" we want BitMIDI to be, but if we provide API support for authenticated users to POST MIDI files, this will allow users to perform their own submissions in the long run. (Things like web forms, and bots).

This is quite the substantial amount of work, and I think can be logically broken down into the following features:

Authenticate API access

Provide the ability to authenticate specific requests that need to be locked down.

e.g.

$ curl -X POST -i -H "Content-Type: application/json" -u basic_username:basic_password https://bitmidi.com/api/my_secure_endpoint

This will probably involve a new table in the current database.

Intentionally doing only basic auth only for now, so that we can add in token based auth later if needed.

API support for submitting a MIDI

Provide the following APIs:

Submitting a MIDI

POST /api/upload?whatever_query_strings_needed_for_unique_identification_of_new_file=blah
content-type: audio/midi
Authorization: Basic test_user:test_pwd

{
    "status": "verifying"
    "job_id": 6969
    "midi_id": ""<this is the thing currently being used to uniquely identify the midi>
}

Querying a submitted MIDI

GET /api/upload_status?job_id=6969

{
    "status": "success"
    "job_id": 6969
    "midi_id" 1234
}