NAV
javascript shell ruby python

Overview

The macgyver API is a REST API which utilizes the JSON data structure. In short, the API works by receiving POST requests from various clients. The requests contain several parameters including the dynamic data, the client key, the program ID, and the program version. The API runs the requested program against the data in the request and responds back with the output of that program.

The macgyver API can work with any language that can issue standard HTTP requests. Macgyver supports cross-origin resource sharing, allowing you to interact securely with our API from a client-side web application.

Authentication

macgyver uses API Keys to both authenticate users and determine who is issuing the query. When you create an account you will be issued both a private and public API key.


API Key Types

Private API Key: private-live-XXXXXX
This key should not be shared publically and should be used for any server side code making a request to the macgyver API.

Public API Key: public-live-XXXXXX
This key can be exposed publically in your javascript. Use this key for cross origin resurce sharing requests. This will only work on origins which have been explicitly added to your allowed origin white list located in your user dashboard.

Build a macgyver Query

require macgyver.js

// This example queries the Face Location program (id: 5w8J9u4z)

macgyver.query({
    payload: {
        key: "live-public-xxxxx",
        id: "5w8J9u4z",
        data: {
          "image_url": "https://askmacgyver.com/images/example.jpg"
        }
    },
    success: function(response) {
       console.log(response);
    }
});

The above command returns JSON structured like this:


{
    "faces": [
        {
            "x": 143,
            "y": 41,
            "width": 87,
            "height": 87
        },
        {
            "x": 87,
            "y": 48,
            "width": 81,
            "height": 81
        }
    ]
}

There are several components to a macgyver query.

URL

https://macgyver.services/

Method

POST

Post Data (JSON Payload)

{ id: "", key: "", version: "", data: {} }



The macgyver Query Payload Object

Parameter Type Description
id Required Program ID - 8 character alpha-numeric code that represents the macgyver program to evaluate against the data. This can be found on the program explore page.
key Required Your unique private or public API key.
version Optional Version of the program you want to use. As publishers improve their programs the results are subject to change. Versioning lets you lock in on a particular version that works for you. If this parameter is ommitted macgyver will use the most recent version.
data Required This is a JSON object which contains the dynamic data you want to evaluate against. The exact structure of this input data is defined by each individual program and can be found on the program explore page.

macgyver.js

require macgyver.js

macgyver.query({
    payload: {
        key: "live-private-xxxxx",
        id: "program-id",
        data: {} 
    },
    success: function(response) {}
});

Client-Side Implementation Using macgyver.js

macgyver.js is a light weight client-side javascript library we offer that allows you to easily query the macgyver API from a web application running javascript.


Compressed - macgyver.js
Uncompressed and Commented - macgyver-debug.js