JavaScript (Browser & Node.js) Client for the Flat REST API
]
The Flat API allows you to easily extend the abilities of the Flat Platform, with a wide range of use cases including the following:
- Creating and importing new music scores using MusicXML or MIDI files
- Browsing, updating, copying, exporting the user's scores (for example in MP3, WAV or MIDI)
- Managing educational resources with Flat for Education: creating & updating the organization accounts, the classes, rosters and assignments.
You can find the API reference including code samples and our OpenAPI Specification at the following url: https://flat.io/developers/api/reference.
To request some API credentials, please visit https://flat.io/developers.
This JavaScript package is automatically generated by the Swagger Codegen project.
Installation
npm
$ npm install flat-api --save
git
$ npm install git://github.com/FlatIO/api-client-js --save
For browser
bower
$ bower install flat-api
git / github
The library also works in the browser environment via npm and browserify.
A build is available in the build
directory, you can also rebuild the library:
$ npm install -d && npm run build
$ ls -1 build
flat-api.js
flat-api.js.map
flat-api.min.js
Then include bundle.js in the HTML pages.
Getting Started
Please follow the installation instruction and execute the following JS code:
var FlatApi = require('flat-api');
FlatApi.ApiClient.instance.authentications.OAuth2.accessToken = 'YOUR_ACCES_TOKEN';
var flatAccountApi = new FlatApi.AccountApi();
flatAccountApi.getAuthenticatedUser(function(error, data, response) {
if (error) {
console.error(error);
}
else {
console.log('Successfully retrieved user profile: ', data);
}
});
Documentation for API Endpoints
All URIs are relative to https://api.flat.io/v2
Class | Method | HTTP request | Description |
---|
FlatApi.AccountApi | getAuthenticatedUser | GET /me | Get current user profile |
FlatApi.GroupApi | getGroupScores | GET /groups/{group}/scores | List group's scores |
FlatApi.ScoreApi | addScoreCollaborator | POST /scores/{score}/collaborators | Add a new collaborator |
FlatApi.ScoreApi | createScore | POST /scores | Create a new score |
FlatApi.ScoreApi | createScoreRevision | POST /scores/{score}/revisions | Create a new revision |
FlatApi.ScoreApi | deleteScore | DELETE /scores/{score} | Delete a score |
FlatApi.ScoreApi | deleteScoreComment | DELETE /scores/{score}/comments/{comment} | Delete a comment |
FlatApi.ScoreApi | editScore | PUT /scores/{score} | Edit a score's metadata |
FlatApi.ScoreApi | forkScore | POST /scores/{score}/fork | Fork a score |
FlatApi.ScoreApi | gerUserLikes | GET /users/{user}/likes | List liked scores |
FlatApi.ScoreApi | getGroupScores | GET /groups/{group}/scores | List group's scores |
FlatApi.ScoreApi | getScore | GET /scores/{score} | Get a score's metadata |
FlatApi.ScoreApi | getScoreCollaborator | GET /scores/{score}/collaborators/{collaborator} | Get a collaborator |
FlatApi.ScoreApi | getScoreCollaborators | GET /scores/{score}/collaborators | List the collaborators |
FlatApi.ScoreApi | getScoreComments | GET /scores/{score}/comments | List comments |
FlatApi.ScoreApi | getScoreRevision | GET /scores/{score}/revisions/{revision} | Get a score revision |
FlatApi.ScoreApi | getScoreRevisionData | GET /scores/{score}/revisions/{revision}/{format} | Get a score revision data |
FlatApi.ScoreApi | getScoreRevisions | GET /scores/{score}/revisions | List the revisions |
FlatApi.ScoreApi | getUserScores | GET /users/{user}/scores | List user's scores |
FlatApi.ScoreApi | markScoreCommentResolved | PUT /scores/{score}/comments/{comment}/resolved | Mark the comment as resolved |
FlatApi.ScoreApi | markScoreCommentUnresolved | DELETE /scores/{score}/comments/{comment}/resolved | Mark the comment as unresolved |
FlatApi.ScoreApi | postScoreComment | POST /scores/{score}/comments | Post a new comment |
FlatApi.ScoreApi | removeScoreCollaborator | DELETE /scores/{score}/collaborators/{collaborator} | Delete a collaborator |
FlatApi.ScoreApi | updateScoreComment | PUT /scores/{score}/comments/{comment} | Update an existing comment |
FlatApi.UserApi | gerUserLikes | GET /users/{user}/likes | List liked scores |
FlatApi.UserApi | getUser | GET /users/{user} | Get a public user profile |
FlatApi.UserApi | getUserScores | GET /users/{user}/scores | List user's scores |
Documentation for Models
OAuth2
- Type: OAuth
- Flow: accessCode
- Authorization URL: https://flat.io/auth/oauth
- Scopes:
- account.public_profile: Provides access to the basic person's public profile. Education profiles may be anonymized with this scope, you can request the scope `education_profile` to access to the a basic education account profile.
- account.education_profile: Provides access to the basic person's education profile and public organization information.
- scores.readonly: Allows read-only access to all a user's scores. You won't need this scope to read public scores.
- scores.social: Allow to post comments and like scores
- scores: Full, permissive scope to access all of a user's scores.
Author
Flat - developers@flat.io