Using the MarketPlace API
This article presents the API that allows you to publish add-ons for BlueMind as well as their versions on the MarketPlace.
You can download this API on the BlueMind MarketPlace.
API key
To use the API, you need your API key which you can find in the admin interface: https://marketplace.blue-mind.net/admin/. This API key is editable by the website administrator only.
My plugins and their versions
To find out what plugins you've published, their status (published or unpublished), their current version, and much more, you must make a GET request in the URL: https://marketplace.blue-mind.net/addons/api/plugins/. This request returns information in JSON format. The API key associated with the user making the request must be included as a query header in this format: "api-key: the_api_key".
Here is an example of a Python code you can use to make this request:
GET /api/plugins/
import requests
headers = {
'api-key': 'your_api_key'
}
URL = 'https://marketplace.blue-mind.net/addons/api/plugins/'
req = requests.get(URL, headers=headers, verify=False)
print "Status code : " + str(req.status_code)
if req.text:
print "Contents : " + str(json.dumps(req.json(), indent=4, sort_keys=True))
Don't forget to replace the API key by the key associated with your MarketPlace account.
Examples of implementations in other languages are provided at the end of this page. If you want to build the request in a language that is not included, you can develop a generated frame example:
GET /addons/api/plugins/ HTTP/1.1
Host: marketplace.blue-mind.net
Content-Length: 51
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.3.0 CPython/2.7.5+ Linux/3.11.0-12-generic
api-key: your_api_key
Specific plugin
To obtain information on a specific plugin (whose ID you know), you can make a GET request in the URL: https://marketplace.blue-mind.net/addons/api/plugin/{id}/ - {id} being the plugin's ID. This request returns information on the plugin in JSON format if the user is the owner of the plugin, otherwise it will return an error 403. This request also requires the API key to be included as a request header in this format: "api-key: the_api_key".
Here is an example of a Python code you can use to make this request:
GET /api/plugin/1
import requests
headers = {
'api-key': 'your_api_key'
}
URL = 'https://marketplace.blue-mind.net/addons/api/plugin/1/'
req = requests.get(URL, headers=headers, verify=False)
print "Status code : " + str(req.status_code)
if req.text:
print "Contents : " + str(json.dumps(req.json(), indent=4, sort_keys=True))
Examples of implementations in other languages are provided at the end of this page. If you want to build the request in a language that is not included, you can develop a generated frame example:
GET /addons/api/plugin/1/ HTTP/1.1
Host: [marketplace.blue-mind.net](http://marketplace.blue-mind.net)
Content-Length: 51
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.3.0 CPython/2.7.5+ Linux/3.11.0-12-generic
api-key: your_api_key
Adding a plugin
To add a plugin, you must build a POST request containing the information needed to create it in JSON format and send this request to the URL https://marketplace.blue-mind.net/addons/api/plugins/. The information needed is:
Key Name | Required | Key Description |
---|---|---|
api_key | yes | Identifier of the user who will create the plugin |
name | yes | Name of the plugin to be created |
shortdesc | yes | Short description of the plugin to be created (shown under the title) |
description | yes | Long description of the plugin to be created (shown under screenshots) |
license | yes | Publication license for the plugin to be created |
installation_instructions | yes | Plugin installation procedure |
home_url | no | URL of the website associated with the plugin |
The request being a "multipart/form-data" request, we have chosen to associate JSON data with the "json" name. If you fail to follow this convention, the request will not succeed.
You can also add images linked to the plugin by attaching them as files associated with the POST request. Image names must follow this convention:
Name | Description |
---|---|
thumbnail | The image associated with the plugin logo. |
* | Any image with another name will be imported as a screenshot for the plugin. |
There is no limit to the number of screenshots.
Here is an example of a Python code that creates a plugin with a logo and two screenshots:
POST /api/plugins/
import requests, json
data = {
'api_key': 'your_api_key',
'name': 'Super plugin',
'shortdesc': 'A short description',
'description': 'A long description',
'license': 'A license',
'installation_instructions': 'Some instructions',
'home_url': "http://www.blue-mind.net"
}
files = {
'thumbnail': open('/home/user/Images/my_thumbnail.jpg', 'rb'),
'screen1': open('/home/user/Images/my_screenshot1.png', 'rb'),
'screen2': open('/home/user/Images/my_screenshot2.png', 'rb')
}
URL = 'https://marketplace.blue-mind.net/addons/api/plugins/'
req = requests.post(URL, files=files, data={'json': json.dumps(data)}, verify=False)
print "Status code : " + str(req.status_code)
Examples of implementations in other languages are provided at the end of this page. If you want to build the request in a language that is not included, you can develop a generated frame example:
POST /addons/api/plugins/ HTTP/1.1
Host: [marketplace.blue-mind.net](http://marketplace.blue-mind.net)
Content-Length: 279271
Content-Type: multipart/form-data; boundary=1824dd5f14f14e57bb2b2a27424628db
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.3.0 CPython/2.7.5+ Linux/3.11.0-12-generic
--1824dd5f14f14e57bb2b2a27424628db
Content-Disposition: form-data; name="json"
{"home_url": "[http://www.blue-mind.net](http://www.blue-mind.net)", "name": "Super plugin", "license": "A license", "installation_instructions": "Some instructions", "shortdesc": "A short description", "api_key": "your_api_key", "description": "A long description"}
--1824dd5f14f14e57bb2b2a27424628db
Content-Disposition: form-data; name="screen2"; filename="my_screenshot2.png"
[... DATA ...]
--1824dd5f14f14e57bb2b2a27424628db--
--1824dd5f14f14e57bb2b2a27424628db
Content-Disposition: form-data; name="screen1"; filename="my_screenshot1.png"
[... DATA ...]
--1824dd5f14f14e57bb2b2a27424628db--
--1824dd5f14f14e57bb2b2a27424628db
Content-Disposition: form-data; name="thumbnail"; filename="my_thumbnail.jpg"
[... DATA ...]
--1824dd5f14f14e57bb2b2a27424628db--
Adding a plugin version
To add a plugin version to a plugin you own, you must build a POST request containing the information necessary to create the version in JSON format and send this request to the URL: https://marketplace.blue-mind.net/addons/api/plugin_version/. This information is:
Key Name | Required | Key Description |
---|---|---|
api_key | yes | Identifier of the user who will create the plugin |
plugin_name | yes | Name of the plugin associated with the version |
version | yes | New plugin version number |
target_bm_versions | yes | BlueMind versions concerned by this new version |
release_notes | yes | Description of the reason for the new version |
The request being a "multipart/form-data" request, we have chosen to associate JSON data with the "json" name. If you fail to follow this convention, the request will not succeed.
You must associate a file to this new version (the file to download) by attaching it to the POST request with the name "package".
Here is an example of a Python code that adds version 0.2 for the "Super plugin" plugin:
POST /api/plugin_version/
import requests, json
data = {
'api_key': 'your_api_key',
'plugin_name': 'Super plugin',
'version': '0.2',
'target_bm_versions': '3.x',
'release_notes': 'Brand new release'
}
files = {
'package': open('/home/user/Files/super_plugin.jar', 'rb')
}
URL = 'https://marketplace.blue-mind.net/addons/api/plugin_version/'
req = requests.post(URL, files=files, data={'json': json.dumps(data)}, verify=False)
print "Status code : " + str(req.status_code)
The new version will be rejected if it doesn't include a file, and if the plugin isn't yours (unless you are a MarketPlace administrator).
Examples of implementations in other languages are provided at the end of this page. If you want to build the request in a language that is not included, you can develop a generated frame example:
POST /addons/api/plugin_version/ HTTP/1.1
Host: [marketplace.blue-mind.net](http://marketplace.blue-mind.net)
Content-Length: 1191498
Content-Type: multipart/form-data; boundary=947a3f6396a244a99118fd5a3faa5204
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.3.0 CPython/2.7.5+ Linux/3.11.0-12-generic
--947a3f6396a244a99118fd5a3faa5204
Content-Disposition: form-data; name="json"
{"api_key": "your_api_key", "release_notes": "Ceci est une nouvelle release", "version": "0.2", "plugin_name": "Super plugin", "target_bm_versions": "3.x"}
--947a3f6396a244a99118fd5a3faa5204
Content-Disposition: form-data; name="package"; filename="super_plugin.jar"
[... DATA ...]
--947a3f6396a244a99118fd5a3faa5204--
Using the API in different languages
In Python
Here is a full script that includes earlier scripts and allows you to make POST or GET requests (depending on the comments) on the MarketPlace:
Full script
#!/usr/bin/env python
# -\*- coding: utf-8 -\*-
import requests, json
WEBSITE = "https://marketplace.blue-mind.net/"
API_KEY = "your_api_key"
#### POST PLUGIN
data = {
'api_key': API_KEY,
'name': 'Super plugin',
'shortdesc': 'A short description',
'description': 'A long description',
'license': 'A license',
'installation_instructions': 'Several instructions !',
'home_url': "http://www.blue-mind.net"
}
files = {
'thumbnail': open('/home/user/Images/thumbnail.jpg', 'rb'),
'screen1': open('/home/user/Images/screenshot1.png', 'rb'),
'screen2': open('/home/user/Images/screenshot1.png', 'rb')
}
URL = WEBSITE + 'addons/api/plugins/'
#### POST PLUGIN VERSION
# data = {
# 'api_key': API_KEY,
# 'plugin_name': 'Super plugin',
# 'version': '0.2',
# 'target_bm_versions': '3.x',
# 'release_notes': 'We just put out a new release'
# }
#
# files = {
# 'package': open('/home/user/Files/super_plugin.jar', 'rb')
# }
#
# URL = WEBSITE + 'addons/api/plugin_version/'
#### POST REQUEST
req = requests.post(URL, files=files, data={'json': json.dumps(data)}, verify=False)
#### GET PLUGINS
# headers = {
# 'api-key': API_KEY
# }
#
# URL = WEBSITE + 'addons/api/plugins/'
#
# #### GET REQUEST
# req = requests.get(URL, headers=headers, verify=False)
#### POST OR GET RESPONSE
print "Status code : " + str(req.status_code)
if req.text:
print "Contents : " + str(json.dumps(req.json(), indent=4, sort_keys=True))
Download the source code: api_python.py
In Java
The following code extracts give you an idea of what you need to do in Java to have operational GET and POST requests. They use the Apache HTTP and JSON-Simple APIs.
GET /addons/api/plugins
private static HttpClient httpClient = StaticTools.getHttpClient(true);
private static String API_KEY = "your_api_key";
private static String WEBSITE = "https://marketplace.blue-mind.net/";
private static void getPlugins() throws IOException {
HttpGet httpGet = new HttpGet(WEBSITE + "/addons/api/plugins/");
httpGet.addHeader("api-key", API_KEY);
ResponseHandler<String> handler = new BasicResponseHandler();
HttpResponse rep = httpClient.execute(httpGet);
if (rep != null) {
int statusCode = rep.getStatusLine().getStatusCode();
System.out.println("Status code : " + statusCode);
if (statusCode == 200) {
System.out.println("Contents : " + handler.handleResponse(rep));
}
}
}
GET /addons/api/plugin/id
private static HttpClient httpClient = StaticTools.getHttpClient(true);
private static String API_KEY = "your_api_key";
private static String WEBSITE = "https://marketplace.blue-mind.net/";
private static void getPlugin(int id) throws IOException {
HttpGet httpGet = new HttpGet(WEBSITE + "/addons/api/plugin/" + id);
httpGet.addHeader("api-key", API_KEY);
ResponseHandler<String> handler = new BasicResponseHandler();
HttpResponse rep = httpClient.execute(httpGet);
if (rep != null) {
int statusCode = rep.getStatusLine().getStatusCode();
System.out.println("Status code : " + statusCode);
if (statusCode == 200) {
System.out.println("Contents : " + handler.handleResponse(rep));
}
}
}
POST /addons/api/plugins
private static HttpClient httpClient = StaticTools.getHttpClient(true);
private static String API_KEY = "your_api_key";
private static String WEBSITE = "https://marketplace.blue-mind.net/";
@SuppressWarnings("unchecked")
private static void postPlugin() throws IOException {
HttpPost httpPost = new HttpPost(WEBSITE + "/addons/api/plugins/");
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
ContentType contentType = ContentType.getOrDefault(null);
// Json part
JSONObject j = new JSONObject();
j.put("api_key", API_KEY);
j.put("name", "Super plugin");
j.put("shortdesc", "A short description");
j.put("description", "A long description");
j.put("license", "A license");
j.put("installation_instructions", "Several instructions");
j.put("home_url", "http://www.blue-mind.net");
StringBody json = new StringBody(j.toString(), contentType);
// Files part
FileBody thumbnail = new FileBody(new File("/home/user/Images/thumbnail.jpg"));
FileBody screen1 = new FileBody(new File("/home/user/Images/screenshot1.png"));
FileBody screen2 = new FileBody(new File("/home/user/Images/screenshot2.png"));
// Grouping
builder.addPart("json", json);
builder.addPart("thumbnail", thumbnail);
builder.addPart("screen1", screen1);
builder.addPart("screen2", screen2);
httpPost.setEntity(builder.build());
HttpResponse rep = httpClient.execute(httpPost);
if (rep != null) {
int statusCode = rep.getStatusLine().getStatusCode();
System.out.println("Status code : " + statusCode);
}
}
POST /addons/api/plugin_version
private static HttpClient httpClient = StaticTools.getHttpClient(true);
private static String API_KEY = "your_api_key";
private static String WEBSITE = "https://marketplace.blue-mind.net/";
@SuppressWarnings("unchecked")
private static void postPluginVersion() throws IOException {
HttpPost httpPost = new HttpPost(WEBSITE + "/addons/api/plugin_version/");
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
ContentType contentType = ContentType.getOrDefault(null);
// Json part
JSONObject j = new JSONObject();
j.put("api_key", API_KEY);
j.put("plugin_name", "Super plugin");
j.put("version", "0.2");
j.put("target_bm_versions", "3.x");
j.put("release_notes", "On vient de faire une nouvelle release");
StringBody json = new StringBody(j.toString(), contentType);
// Files part
FileBody pack = new FileBody(new File("/home/user/Files/super_plugin.jar"));
// Grouping
builder.addPart("json", json);
builder.addPart("package", pack);
httpPost.setEntity(builder.build());
HttpResponse rep = httpClient.execute(httpPost);
if (rep != null) {
int statusCode = rep.getStatusLine().getStatusCode();
System.out.println("Status code : " + statusCode);
}
}
Download the source code: api_java.zip