Hacker News new | ask | show | jobs
by timmm 3640 days ago
>You have docs for accessing it but I can't find any for me building an api endpoint. The docs also seem to suggest I use a client library called "kittn", which I'm pretty sure is wrong.

No you are absolutely right. The docs are not built out yet and you are seeing the template data. We will curate this process and provide documentation. But a quick overview is as follows.

The API endpoint is static.

POST https://macgyver.services

The payload is a dynamic JSON object that has the following properties.

program id, user key, program_data (as defined on the program input page)

It would look something like this -

{ id: "9s9z6J6b", key: "private-live-6w9c2p10G5p3b6y" program_data: {} }

As far as how the program should function I can just show you the addition program as example.

The program should be called "main" with a file extension that corresponds to the run time you want macgyver to call.

So the addition program is a javascript file called "main.js"

// user specified data format

var data = '';

var sum =0;

data = JSON.parse(data);

for(var i=0; i<data.values.length; i++){ sum += data.values[i]; }

var result = { "sum" : sum }

// This gets returned to the client

console.log(JSON.stringify(result));

The variable 'data' will have it's string content be populated with the clients payload send data at the time of execution.

https://askmacgyver.com/explore/program/addition/2c2c5w7W

There is some information on that here.

https://askmacgyver.com/how-it-works