API

The M3O API consists of a set of many public apis all consumed through a single gateway.

Overview

M3O APIs are a standard set of http/json APIs which act as programmable building blocks for rapid development of any product or services. Pick up and use one or more APIs as easily as importing a library and making a function call from a library. M3O APIs are hosted versions of Micro Services.

Examples

Here’s a simple helloworld

Curl

curl -H "Authorization: Bearer $M3O_API_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"name": "John"}' \
     https://api.m3o.com/v1/helloworld/call

Find all the shell examples in m3o-sh

Go

Import packages from go.m3o.com

import "go.m3o.com/helloworld"

Create a new client with your API token and call it

helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))

rsp, err := helloworldService.Call(&helloworld.CallRequest{
	"Name": "Alice",
})

fmt.Println(rsp.Message)

Find all the Go examples in m3o-go

JS

Install the m3o package

npm install m3o

Call helloworld like so

const { HelloworldService } = require("m3o/helloworld");

const helloworldService = new HelloworldService(process.env.M3O_API_TOKEN);

// Call returns a personalised "Hello $name" response
async function callTheHelloworldService() {
  const rsp = await helloworldService.call({
    name: "John",
  });
  console.log(rsp);
}

callTheHelloworldService();

Find more JS examples in m3o-js

API Endpoint

The canonical API endpoint is

https://api.m3o.com/v1/

All service endpoints are append like so.

# /v1/[service]/[endpoint]
https://api.m3o.com/v1/helloworld/Call

Authorization

All API calls require a valid API token. New tokens can be generated on the API keys page.

An API token should be passed in the Authorization: Bearer header

Authorization: Bearer $MICRO_API_TOKEN

Data Format

All request/responses are in JSON format and require a Content-Type: application/json header to be passed on each request.

OpenAPI Specs

Find the OpenAPI specs in the spec directory

Public APIs

A list of public APIs can be found on m3o.com/explore