Open Opus is a free and open source API to classical music metadata.
It provides composers, works and performers information to classical music apps such as Concertmaster and Concertino. It's written in PHP and relies on a MySQL database. It's free and everybody can use it directly. Additionally, all Open Opus data is in the public domain and can be freely used.
It's a public RESTful API which returns data in JSON format. There is a wiki explaining all endpoints and data structures. No registration needed.
- Fork and clone this git repository to your webserver (for example, in the
/var/www/
folder) - The Open Opus API uses a shared Open Opus utilities library. Clone it in the same directory
- Create a MySQL database (for example,
openopus
) and load its strucuture
mysql -u USER -p openopus < /var/www/openopus_api/sql/openopus.sql
- Install the Composer vendor packages:
cd /var/www/openopus_api/
composer install
- Create an
inc.php
file from the example:
cd /var/www/openopus_api/lib/
cp inc-example.php inc.php
vim inc.php
- Change variable values in the
lib/inc.php
accordingly to your webserver
Open Opus search functionality needs special configurations on your MySQL database. Update your server's my.cnf
file (paths may vary on different operating systems) to include two extra directives:
innodb_ft_min_token_size = 1
innodb_ft_enable_stopword = 0
To import the full Open Opus dataset to your fork, simply:
- Remove the 2nd line from the
html/dyn/composer/importdump/index.phtml
file - Open the following URL in your web browser:
https://youropenopusfork.com/dyn/composer/importdump/
Replace the domain above with the one your app will use.
Additionally, you can download the data directly through the API:
https://api.openopus.org/work/dump.json
The search database will be renewed automatically every night (see "cache cleaning routines", below). To make the first import, simply run on command line:
php /var/www/openopus_api/cln/omnisearch.php
The Open Opus API uses Google Cloud to store image files. In order to use it, you must:
- Create a
keys
directory in/var/www/openopus_api/
and put your Google Cloudkeyfile.json
in it - Change the Google Cloud variables in the
lib/inc.php
accordingly to your Google account
There are 220 composer portraits in the portraits
directory. If you want to upload them to your cloud:
- Remove the 2nd line from the
html/dyn/composer/portraitupload/index.phtml
file - Open the following URL in your web browser:
https://youropenopusfork.com/dyn/composer/portraitupload/
Replace the domain above with the one your app will use.
The Open Opus API can cache its results, saving server resources. In order to activate this feature you must:
- Give ownership of the public directory to the web server group (e.g.,
www-data
):
chgrp www-data /var/www/openopus_api/html -R
- Set the environment variables for root:
vim /etc/environment
export BASEOPENOPUSDIR="/var/www/openopus_api/html"
- Update crontab for root (this will set the cache-cleaning and search-building routines)
# m h dom mon dow command
0 2 1 * * /var/www/openopus_api/cln/db.sh
0 1 * * * php /var/www/openopus_api/cln/omnisearch.php
There is a single public directory in the project (/html) and it must have its own virtual host on your webserver. (For example, we host it at api.openopus.org.)
The API must be served with HTTPS. You can use a free Let's Encrypt-provided certificate, it's perfectly fine.
Open Opus is a publicly available API, so its CORS settings are fully permissive (Access-Control-Allow-Origin: *
).
If you plan your fork to be more restrictive, you can make it accept requests only from trusted domains. Just remove the first line of the html/.htaccess
file and implement the following configuration in your webserver (it must be placed inside the <virtualhost>
directive):
SetEnvIf Origin ^(https?://(?:.+\.)?(example\.com|expl\.me)(?::\d{1,5})?)$ CORS_ALLOW_ORIGIN=$1
Header append Access-Control-Allow-Origin %{CORS_ALLOW_ORIGIN}e env=CORS_ALLOW_ORIGIN
Header merge Vary "Origin"
Change the domains above to the ones your app will use.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Open Opus is a free, wiki-style, open source database. You can review existing info or add new entries to the database - any help will be appreciated!
Open Opus is free to use but it runs on web servers that cost us money. You can help us by supporting us on Patreon - any amount is more than welcome!
API: GPL v3.0 Data: Public Domain