Microreact
Search
K

Migrating to the new API

This page relates to major changes in Microreact released in 2020

Summary of breaking changes

The new Microreact API only accepts authenticated requests. Calls without an Acccess-Token header will fail with 401 Unauthorized error.
Text
New API
Old API
API Endpoint
https://microreact.org/api/projects/create/
https://microreact.org/api/project/
Documentation
Request body
A valid .microreact JSON file
Old API request payload as documented in https://old.microreact.org/api-docs
Access-Token header
Required (Obtain your access token from https://microreact.org/my-account/settings)
Optional

Converting old API request payload

You can convert an old API request payload to a new .microreact JSON file using the schema convertor endpoint:
cURL + Bash
curl \
--header "Content-type: application/json; charset=UTF-8" \
--request POST \
--data '{ "name": "hayu110x2c0smcm", "data": "https://raw.githubusercontent.com/microreact/data/main/data.csv" }' \
https://microreact.org/api/schema/convert
The response is a valid .microreact JSON file
{
"datasets": {
"dataset-1": {
"file": "data-file-1",
"idFieldName": "id"
}
},
"files": {
"data-file-1": {
"id": "data-file-1",
"format": "text/csv",
"name": "data.csv",
"url": "https://raw.githubusercontent.com/microreact/data/main/data.csv"
}
},
"maps": {
"map-1": {
"title": "Map",
"latitudeField": "__latitude",
"longitudeField": "__longitude"
}
},
"meta": {
"name": "hayu110x2c0smcm"
},
"tables": {
"table-1": {
"dataset": "dataset-1",
"title": "Metadata",
"columns": [
{
"field": "id"
},
{
"field": "__latitude"
},
{
"field": "__longitude"
},
{
"field": "country"
},
{
"field": "__year"
},
{
"field": "__month"
},
{
"field": "__day"
}
]
}
},
"timelines": {
"timeline-1": {
"title": "Timeline",
"dataType": "year-month-day",
"yearField": "__year",
"monthField": "__month",
"dayField": "__day"
}
},
"schema": "https://microreact.org/schema/v1.json"
}
You can also pipe the response into the create project endpoint as in the following example:
curl \
--header "Content-type: application/json; charset=UTF-8" \
--request POST \
--data '{ "name": "hayu110x2c0smcm", "data": "https://raw.githubusercontent.com/microreact/data/main/data.csv" }' \ # Old API request payload as documented in https://old.microreact.org/api-docs
https://microreact.org/api/schema/convert \
| \
curl \
--header "Content-type: application/json; charset=UTF-8" \
--header "Access-Token: eyJhbGciOiJIUzUxMiJ9..." \ # Obtain your access token from https://microreact.org/my-account/settings
--data @- \
https://microreact.org/api/projects/create