Skip to content

Instantly share code, notes, and snippets.

@puentesarrin
Last active November 17, 2017 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save puentesarrin/1939b503820c433274dfcf08b3043e97 to your computer and use it in GitHub Desktop.
Save puentesarrin/1939b503820c433274dfcf08b3043e97 to your computer and use it in GitHub Desktop.
REST API Specifications for Axios

Authorization

Our REST API service uses a key based authorization that could be managed in your Account page. You can find your own API key in form of a 64 character string, and note that we will be able to identify you with it, so please do not share it.

All client requests are authorized using valid API keys via an specific HTTP header or query string. Query string takes priority over HTTP header, so query string will be considered if you send both at the same time.

Sending API key via query string

In order to authorize requests using "api_key" query string, you need to send it as follows:

<HTTP-METHOD> <domain>/api/<version>/<path>?api_key=<api_key>

Sending API key via HTTP header

In order to authorize requests using HTTP header named "X-RMAuth", you need to perform as follows:

<HTTP-METHOD> <domain>/api/<version>/<path>
X-RMAuth: <api_key>

Unauthorized requests

If you send invalid API keys, you are going to get a response with HTTP 403 Forbidden status and the following payload:

{
     "status": {
          "code": null,
          "messages": ["API key is not valid"]
     },
     "data": null
}

Author API

The author API supports creating users that could be used to create drafts.

Creating authors

Creates an author and sets its role as guest editor.

POST /api/1.1/authors

Parameters

Name Type Description
first_name String First name - Required
last_name String Last name - Required
email String User email - Required
password String User password - Required
about_html String User biography - Optional
image_id Integer ID of the uploaded image - Optional

Note

  • image_id can be found as id in Image API response when uploading or editing images.

Response

{
    "id": <id>,
    "name": "paulberry",
    "displayname": "Paul Berry",
    "about_html": "This is me",
    "bio": "",
    "photo": "https://<domain>/res/avatars/default",
    "fb_id": null,
    "profile_url": "https://<domain>/community/paulberry/"
}

Drafts API

The draft API supports creating drafts that could be used to publish content on site.

Creating drafts

Creates a draft and sets current user as author by default.

POST /api/1.1/posts

Parameters

Name Type Description
headline String Headline - Required
body String Body - Optional
subheadline String Subheadline - Optional
tags Array of strings Tags - Optional
primary_tag String Primary tag - Optional
sections Array of strings Sections - Optional
primary_section String Primary section - Optional
og_title String Social headline - Optional
og_description String Social description - Optional
image_id Integer ID of the uploaded image - Optional
manual_image_crops Object Crops calculated when uploading image - Optional

Note

  • primary_section and sections fields are eligible by title using insensitive case mode. "Home" can be passed if you want to set draft in homepage.
  • image_id can be found as id in Image API response when uploading or editing images.
  • manual_image_crops can be also found as manual_image_crops in Image API response when editing images.

Response

The response can contain several fields, but would like to highlight some of them that were specially requested:

Name Type Description
post_url String URL for the draft when is published.
draft_url String Composited by post_url + "?draft=1", which enables users to see draft page.
slug String URL path from post_url.

Image API

The Image API supports uploading and editing images that could be used as splash post image, teaser, social teaser and even other features than posts such as authors creation.

Ratios

Every site in RebelMouse platform has its own image crops configured, these settings are useful when a image is going to be rezised or cropped. So they are considered in every process related to images, and each resized or cropped image has usually a different purpose depending on page type.

For Axios, we have the following ratios configured:

+-------+----+------------+ Code +=======+====+=====+======+ 16x9| - 960x540 | | | | - 480x270 | +-------+----+-----+------+ 2x1 | - 1200x600 | | | | - 600x300 | +-------+----+-----+------+ 2x1 | - 1200x600 | | | | - 600x300 | +-------+----+-----+------+ 1x1 | - 600x600 | +-------+----+-----+------+ 9x16| - 700x1245 | +-------+----+-----+------+

Uploading images

Upload a image sending its content as a part of HTTP request body or sending a URL as part of a JSON document.

POST /api/1.3/images

Parameters

Name Type Description
image_url String A image URL location - Optional

Note

Multiple files can be also sent as part of HTTP request. They are used only if image_url is not used in HTTP request.

Response

For a single image uploaded:

{
     "is_animated_gif": false,
     "task_id": "c3e2a367-24cb-426f-9179-457a0e0ea9ec",
     "height": 511,
     "shortcode_id": "7229TA1498262817",
     "iptc": {
         "by-line": "",
         "caption/abstract": ""
     },
     "id": <id>,
     "shortcode_params": {
         "is_animated_gif": false,
         "crop_info": "%22%7B%22image%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2Forigin.jpg%22%2C%20%22thumbnails%22%3A%20%7B%22origin%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2Forigin.jpg%22%2C%20%2235x35%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F35x35.jpg%22%2C%20%221200x800%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F1200x800.jpg%22%2C%20%22480x270%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F480x270.jpg%22%2C%20%22700x1245%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F700x1245.jpg%22%2C%20%22980x%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F980x.jpg%22%2C%20%22600x%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F600x.jpg%22%2C%20%22600x600%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F600x600.jpg%22%2C%20%22960x540%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F960x540.jpg%22%2C%20%22600x300%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F600x300.jpg%22%2C%20%22210x%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F210x.jpg%22%2C%20%22300x%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F300x.jpg%22%2C%20%22600x400%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F600x400.jpg%22%2C%20%221200x600%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F1200x600.jpg%22%7D%2C%20%22manual_image_crops%22%3A%20%7B%2216x9%22%3A%20%7B%22width%22%3A%20512%2C%20%22top%22%3A%20222%2C%20%22height%22%3A%20289%2C%20%22left%22%3A%200%2C%20%22sizes%22%3A%20%5B%22960x540%22%2C%20%22480x270%22%5D%7D%2C%20%222x1%22%3A%20%7B%22width%22%3A%20512%2C%20%22top%22%3A%20255%2C%20%22height%22%3A%20256%2C%20%22left%22%3A%200%2C%20%22sizes%22%3A%20%5B%221200x600%22%2C%20%22600x300%22%5D%7D%2C%20%223x2%22%3A%20%7B%22width%22%3A%20512%2C%20%22top%22%3A%20169%2C%20%22height%22%3A%20342%2C%20%22left%22%3A%200%2C%20%22sizes%22%3A%20%5B%221200x800%22%2C%20%22600x400%22%5D%7D%2C%20%221x1%22%3A%20%7B%22width%22%3A%20109%2C%20%22top%22%3A%20402%2C%20%22height%22%3A%20109%2C%20%22left%22%3A%200%2C%20%22sizes%22%3A%20%5B%22600x600%22%5D%7D%2C%20%229x16%22%3A%20%7B%22width%22%3A%20117%2C%20%22top%22%3A%20303%2C%20%22height%22%3A%20208%2C%20%22left%22%3A%200%2C%20%22sizes%22%3A%20%5B%22700x1245%22%5D%7D%7D%7D%22%0A",
         "original_size": "512x511",
         "expand": 1
     },
     "thumbnails": {
         "origin": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/origin.jpg",
         "35x35": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/35x35.jpg",
         "1200x800": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/1200x800.jpg",
         "480x270": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/480x270.jpg",
         "700x1245": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/700x1245.jpg",
         "980x": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/980x.jpg",
         "600x": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/600x.jpg",
         "600x600": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/600x600.jpg",
         "960x540": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/960x540.jpg",
         "600x300": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/600x300.jpg",
         "210x": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/210x.jpg",
         "300x": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/300x.jpg",
         "600x400": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/600x400.jpg",
         "1200x600": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/1200x600.jpg"
     },
     "manual_image_crops": {
         "16x9": {
             "width": 512,
             "top": 222,
             "height": 289,
             "left": 0,
             "sizes": [
                 "960x540",
                 "480x270"
             ]
         },
         "2x1": {
             "width": 512,
             "top": 255,
             "height": 256,
             "left": 0,
             "sizes": [
                 "1200x600",
                 "600x300"
             ]
         },
         "3x2": {
             "width": 512,
             "top": 169,
             "height": 342,
             "left": 0,
             "sizes": [
                 "1200x800",
                 "600x400"
             ]
         },
         "1x1": {
             "width": 109,
             "top": 402,
             "height": 109,
             "left": 0,
             "sizes": [
                 "600x600"
             ]
         },
         "9x16": {
             "width": 117,
             "top": 303,
             "height": 208,
             "left": 0,
             "sizes": [
                 "700x1245"
             ]
         }
     },
     "filename": "image_hmXa6R.jpg",
     "width": 512,
     "media_html": "<img src=\"https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/980x.jpg\" id=\"89b1c\" class=\"rm-shortcode\" data-rm-shortcode-id=\"7229TA1498262817\" data-rm-shortcode-name=\"rebelmouse-image\" >",
     "shortcode": "[rebelmouse-image <id> is_animated_gif=false crop_info=\"%22%7B%22image%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2Forigin.jpg%22%2C%20%22thumbnails%22%3A%20%7B%22origin%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2Forigin.jpg%22%2C%20%2235x35%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F35x35.jpg%22%2C%20%221200x800%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F1200x800.jpg%22%2C%20%22480x270%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F480x270.jpg%22%2C%20%22700x1245%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F700x1245.jpg%22%2C%20%22980x%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F980x.jpg%22%2C%20%22600x%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F600x.jpg%22%2C%20%22600x600%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F600x600.jpg%22%2C%20%22960x540%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F960x540.jpg%22%2C%20%22600x300%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F600x300.jpg%22%2C%20%22210x%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F210x.jpg%22%2C%20%22300x%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F300x.jpg%22%2C%20%22600x400%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F600x400.jpg%22%2C%20%221200x600%22%3A%20%22https%3A%2F%2Fs3.amazonaws.com%2Fdev-assets.rbl.ms%2F%3Cid%3E%2F1200x600.jpg%22%7D%2C%20%22manual_image_crops%22%3A%20%7B%2216x9%22%3A%20%7B%22width%22%3A%20512%2C%20%22top%22%3A%20222%2C%20%22height%22%3A%20289%2C%20%22left%22%3A%200%2C%20%22sizes%22%3A%20%5B%22960x540%22%2C%20%22480x270%22%5D%7D%2C%20%222x1%22%3A%20%7B%22width%22%3A%20512%2C%20%22top%22%3A%20255%2C%20%22height%22%3A%20256%2C%20%22left%22%3A%200%2C%20%22sizes%22%3A%20%5B%221200x600%22%2C%20%22600x300%22%5D%7D%2C%20%223x2%22%3A%20%7B%22width%22%3A%20512%2C%20%22top%22%3A%20169%2C%20%22height%22%3A%20342%2C%20%22left%22%3A%200%2C%20%22sizes%22%3A%20%5B%221200x800%22%2C%20%22600x400%22%5D%7D%2C%20%221x1%22%3A%20%7B%22width%22%3A%20109%2C%20%22top%22%3A%20402%2C%20%22height%22%3A%20109%2C%20%22left%22%3A%200%2C%20%22sizes%22%3A%20%5B%22600x600%22%5D%7D%2C%20%229x16%22%3A%20%7B%22width%22%3A%20117%2C%20%22top%22%3A%20303%2C%20%22height%22%3A%20208%2C%20%22left%22%3A%200%2C%20%22sizes%22%3A%20%5B%22700x1245%22%5D%7D%7D%7D%22%0A\" original_size=\"512x511\" expand=1]",
     "image_original_url": "https://s3.amazonaws.com/dev-assets.rbl.ms/<id>/origin.jpg"
}

For multiple images uploaded:

It takes the same schema for each image uploaded but in form of an array.

Editing images

Editing an image for creating some others with certain dimensions.

PUT /api/1.3/images/<id>

Parameters

Name Type Description
image_url String A image URL location - Required
manual_image_crops Object Crop setting for resizing image - Optional

Manual Image Crops

It depends on ratios configured per site. It must be a objects, whose keys must be the ratio codes and the values should contain the following information:

Name Type Description
top Integer Absolute top coordinate
left Integer Absolute left coordinate
height Integer Absolute height coordinate
width Integer Absolute width coordinate
imgHeight Integer Width of the original image
imgWidth Integer Height of the original image

Example

{
 "16x9": {
     "top": 222,
     "left": 0,
     "height": 289,
     "width": 512,
     "imgWidth": 512,
     "imgHeight": 511
 },
 "2x1": {
     "top": 255,
     "left": 0,
     "height": 256,
     "width": 512,
     "imgWidth": 512,
     "imgHeight": 511
 },
 "3x2": {
     "top": 169,
     "left": 0,
     "height": 342,
     "width": 512,
     "imgWidth": 512,
     "imgHeight": 511
 },
 "1x1": {
     "top": 402,
     "left": 0,
     "height": 109,
     "width": 109,
     "imgWidth": 512,
     "imgHeight": 511
 },
 "9x16": {
     "top": 303,
     "left": 0,
     "height": 208,
     "width": 117,
     "imgWidth": 512,
     "imgHeight": 511
 }
}

Response

It takes the same schema than uploading images. Only one image is permitted to edit per request.

Webhooks

Webhooks allows you to receive a notification to certain events from RebelMouse platform. HTTP POST requests are performed for the configured URL you provide us, these requests are formed with the following headers:

Name Value
User-Agent RebelMouse/0.1 Mozilla/5.0 (compatible; http://rebelmouse.com) Gecko/20100101 Firefox/7.0.1
Content-Type application/json

Published post

You can receive a notification when a post is published, you are going to receive the following information:

Name Type Description
post_id Integer ID of the post
post_url String URL for the published post
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment