Appearance
Creating a score
Introduction
This tutorial will guide you through the process of creating a score using the API. We will cover the following steps:
- Creating a score specified by URL
- Creating a view of that score
- Deleting the view
- Deleting the score
Prerequisites
Before you can create a score, you must authenticate with the API. If you haven't done this yet, please see our authentication tutorial.
Steps
Step 1: Create a score
Create a score using the score_create API specifying a score by URL:
sh
curl --request POST \
--url https://api.sibelius.avid.com/score-storage/v1/scores \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--data '{"url": "https://sibeliusprdeastus550.blob.core.windows.net/public/example-scores/bach-ein-feste-burg-ist-unser-gott.sib"}'
js
const http = require("https");
const options = {
method: "POST",
hostname: "api.sibelius.avid.com",
port: null,
path: "/score-storage/v1/scores",
headers: {
Authorization: "Bearer <ACCESS_TOKEN>",
},
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(
JSON.stringify({
url: "https://sibeliusprdeastus550.blob.core.windows.net/public/example-scores/bach-ein-feste-burg-ist-unser-gott.sib",
}),
);
req.end();
py
import http.client
conn = http.client.HTTPSConnection("api.sibelius.avid.com")
payload = "{\"url\": \"https://sibeliusprdeastus550.blob.core.windows.net/public/example-scores/bach-ein-feste-burg-ist-unser-gott.sib\"}"
headers = { 'Authorization': "Bearer <ACCESS_TOKEN>" }
conn.request("POST", "/score-storage/v1/scores", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sibelius.avid.com/score-storage/v1/scores"
payload := strings.NewReader("{\"url\": \"https://sibeliusprdeastus550.blob.core.windows.net/public/example-scores/bach-ein-feste-burg-ist-unser-gott.sib\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <ACCESS_TOKEN>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
cs
var client = new RestClient("https://api.sibelius.avid.com/score-storage/v1/scores");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <ACCESS_TOKEN>");
request.AddParameter("undefined", "{\"url\": \"https://sibeliusprdeastus550.blob.core.windows.net/public/example-scores/bach-ein-feste-burg-ist-unser-gott.sib\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
swift
import Foundation
let headers = ["Authorization": "Bearer <ACCESS_TOKEN>"]
let parameters = ["url": "https://sibeliusprdeastus550.blob.core.windows.net/public/example-scores/bach-ein-feste-burg-ist-unser-gott.sib"] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sibelius.avid.com/score-storage/v1/scores")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
java
HttpResponse<String> response = Unirest.post("https://api.sibelius.avid.com/score-storage/v1/scores")
.header("Authorization", "Bearer <ACCESS_TOKEN>")
.body("{\"url\": \"https://sibeliusprdeastus550.blob.core.windows.net/public/example-scores/bach-ein-feste-burg-ist-unser-gott.sib\"}")
.asString();
We used one of our Sibelius example scores for this tutorial. You can
also reference your own scores in the same way. :::
If successful, you'll receive a response containing the details of the score you created:
json
{
"id": "5622a9c1-9bc2-4a08-bea2-371d654b559b"
"url": "https://sibeliusprdeastus550.blob.core.windows.net/public/example-scores/bach-ein-feste-burg-ist-unser-gott.sib"
…
}
Make a note of the id
value, as you will need it to create a view of the score.
Step 2: Create a view
Create a view of the score using the view_create API specifying the id
of the score you created in step 1:
sh
curl --request POST \
--url https://api.sibelius.avid.com/score-viewer/v1/views \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--data '{"score_id": "5622a9c1-9bc2-4a08-bea2-371d654b559b"}'
js
const http = require("https");
const options = {
method: "POST",
hostname: "api.sibelius.avid.com",
port: null,
path: "/score-viewer/v1/views",
headers: {
Authorization: "Bearer <ACCESS_TOKEN>",
},
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ score_id: "5622a9c1-9bc2-4a08-bea2-371d654b559b" }));
req.end();
py
import http.client
conn = http.client.HTTPSConnection("api.sibelius.avid.com")
payload = "{\"score_id\": \"5622a9c1-9bc2-4a08-bea2-371d654b559b\"}"
headers = { 'Authorization': "Bearer <ACCESS_TOKEN>" }
conn.request("POST", "/score-viewer/v1/views", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sibelius.avid.com/score-viewer/v1/views"
payload := strings.NewReader("{\"score_id\": \"5622a9c1-9bc2-4a08-bea2-371d654b559b\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <ACCESS_TOKEN>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
cs
var client = new RestClient("https://api.sibelius.avid.com/score-viewer/v1/views");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <ACCESS_TOKEN>");
request.AddParameter("undefined", "{\"score_id\": \"5622a9c1-9bc2-4a08-bea2-371d654b559b\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
swift
import Foundation
let headers = ["Authorization": "Bearer <ACCESS_TOKEN>"]
let parameters = ["score_id": "5622a9c1-9bc2-4a08-bea2-371d654b559b"] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sibelius.avid.com/score-viewer/v1/views")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
java
HttpResponse<String> response = Unirest.post("https://api.sibelius.avid.com/score-viewer/v1/views")
.header("Authorization", "Bearer <ACCESS_TOKEN>")
.body("{\"score_id\": \"5622a9c1-9bc2-4a08-bea2-371d654b559b\"}")
.asString();
If successful, you'll receive a response containing the details of the score you created:
json
{
"id": "ccsYUgYiBMmKRjezG4AYq",
"score_id": "5622a9c1-9bc2-4a08-bea2-371d654b559b",
"self_link": "https://sibl.pub/v/ccsYUgYiBMmKRjezG4AYq"
}
Now you may open the self_link
URL in a browser to view the score.
Make a note of the id
value, as you will need it to delete the view.
Step 3: Delete the view
By default, views expire automatically. For the purposes of this tutorial, we will delete the view manually using the view_delete API:
sh
curl --request DELETE \
--url https://api.sibelius.avid.com/score-viewer/v1/views/ccsYUgYiBMmKRjezG4AYq \
--header 'Authorization: Bearer <ACCESS_TOKEN>'
js
const http = require("https");
const options = {
method: "DELETE",
hostname: "api.sibelius.avid.com",
port: null,
path: "/score-viewer/v1/views/ccsYUgYiBMmKRjezG4AYq",
headers: {
Authorization: "Bearer <ACCESS_TOKEN>",
},
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
py
import http.client
conn = http.client.HTTPSConnection("api.sibelius.avid.com")
headers = { 'Authorization': "Bearer <ACCESS_TOKEN>" }
conn.request("DELETE", "/score-viewer/v1/views/ccsYUgYiBMmKRjezG4AYq", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.sibelius.avid.com/score-viewer/v1/views/ccsYUgYiBMmKRjezG4AYq"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <ACCESS_TOKEN>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
cs
var client = new RestClient("https://api.sibelius.avid.com/score-viewer/v1/views/ccsYUgYiBMmKRjezG4AYq");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", "Bearer <ACCESS_TOKEN>");
IRestResponse response = client.Execute(request);
swift
import Foundation
let headers = ["Authorization": "Bearer <ACCESS_TOKEN>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sibelius.avid.com/score-viewer/v1/views/ccsYUgYiBMmKRjezG4AYq")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
java
HttpResponse<String> response = Unirest.delete("https://api.sibelius.avid.com/score-viewer/v1/views/ccsYUgYiBMmKRjezG4AYq")
.header("Authorization", "Bearer <ACCESS_TOKEN>")
.asString();
On success the API should return a 202 Accepted
status code with no content.
Now - try opening the viewer URL you created in step 2. You should see a 404 Not Found
error.
Step 4: Delete the score
Finally, delete the score using the score_delete API:
sh
curl --request DELETE \
--url https://api.sibelius.avid.com/score-storage/v1/scores/5622a9c1-9bc2-4a08-bea2-371d654b559b \
--header 'Authorization: Bearer <ACCESS_TOKEN>'
js
const http = require("https");
const options = {
method: "DELETE",
hostname: "api.sibelius.avid.com",
port: null,
path: "/score-storage/v1/scores/5622a9c1-9bc2-4a08-bea2-371d654b559b",
headers: {
Authorization: "Bearer <ACCESS_TOKEN>",
},
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
py
import http.client
conn = http.client.HTTPSConnection("api.sibelius.avid.com")
headers = { 'Authorization': "Bearer <ACCESS_TOKEN>" }
conn.request("DELETE", "/score-storage/v1/scores/5622a9c1-9bc2-4a08-bea2-371d654b559b", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.sibelius.avid.com/score-storage/v1/scores/5622a9c1-9bc2-4a08-bea2-371d654b559b"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <ACCESS_TOKEN>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
cs
var client = new RestClient("https://api.sibelius.avid.com/score-storage/v1/scores/5622a9c1-9bc2-4a08-bea2-371d654b559b");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", "Bearer <ACCESS_TOKEN>");
IRestResponse response = client.Execute(request);
swift
import Foundation
let headers = ["Authorization": "Bearer <ACCESS_TOKEN>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sibelius.avid.com/score-storage/v1/scores/5622a9c1-9bc2-4a08-bea2-371d654b559b")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
java
HttpResponse<String> response = Unirest.delete("https://api.sibelius.avid.com/score-storage/v1/scores/5622a9c1-9bc2-4a08-bea2-371d654b559b")
.header("Authorization", "Bearer <ACCESS_TOKEN>")
.asString();
Similar to the view deletion, the API should return a 202 Accepted
status code with no content.
Further information
- score_create API reference
- score_delete API reference
- view_create API reference
- view_delete API reference