Connector API Example: Pokéfusion

Welcome to the Pokefusion Connector API Example! We'll use this as a
basic template for creating new Connector APIs, or APIs that appear as a
part of the Autocode Standard Library. An example
of an API reference page is available below.
Once this API has been shipped, you can also use it as part of the Autocode editor
autocomplete by typing await lib.username.@
for development APIs and await lib.username.
for production APIs. (Where username
is the username of the account the API has
been shipped to.)
And and in-editor API autocomplete example...
At this point, we can also hook it up to Slack
webhooks and more in Autocode to produce output like:
About this API
To reiterate, you can use this template to deploy a basic Pokefusion API to your
personal Autocode account, which can then be used as a part of the
Autocode Standard Library.
Anything in your projects functions/
directory in Autocode is treated as an
API endpoint and will be automatically exported as an HTTP(S) enabled web
endpoint or webhook. (Connector APIs can not have webhooks attached to them, they
are HTTP(S)-only.)
This sample API has one endpoint, functions/__main__.js
which
will appear as the root endpoint. It accepts two parameters,
headPokemon
and bodyPokemon
for generating random fused Pokemon based on
pokemon.alexonsager.net. The parameters
are documented by modifying the comments above the exported function, based
on the FunctionScript specification
like so;
/**
* Fuse any two Pokemon of the original (some may say only) 151.
* @param {string} headPokemon The name of the first Pokemon to fuse as a head. Will randomize if not provided.
* @param {string} bodyPokemon The name of the second Pokemon to fuse as a body. Will randomize if not provided.
* @returns {object} pokefusion The fused Pokemon
* @ {string} name The name of the fused Pokemon
* @ {string} image_url The URL to an image of the fused Pokemon
* @ {object} fused The Pokemon fusion
* @ {string} head The Pokemon used in the head of the fusion
* @ {string} body The Pokemon used in the body of the fusion
*/
module.exports = async (headPokemon = null, bodyPokemon = null) => {
// API logic implementation goes here
return {}; // Return schema should match object schema specified above
};
Deploying this Connector API
You can deploy this API instantly using the Open in Autocode button:

You'll be asked to Fork your project, which will create a new instance of this
project on your personal account. From there you have full access to code.
Using and Modifying this API
You can modify and test run this API at any time from the Autocode
editor. Additionally, once deployed, this project will have an API Reference page
associated with it at autocode.com/lib/username/connector-pokefusion
(or whatever your
username
/ api-name
combination is, if not connector-pokefusion
).
You can now use this Connector API in projects! You can use it as part of the Autocode
autocomplete by typing await lib.username.@
for development APIs and await lib.username.
for production APIs.
That's it!
Building Connector APIs is easy! We're excited to see what you build.