How to design an easy to use api

If you don't understand computer programming, check out my guide on how to understand computer programming.

19
STEPS
TOOLS

An API is an APPLICATION PROGRAMMING INTERFACE. It is an interface that helps you program for someone else's program. Twitter's API lets people make twitter apps.

Twitter provides app makers with certain CLASSES, FUNCTIONS, and VARIABLES so that they can use them to interact with Twitter's website. Any app that can post to Twitter used the Twitter API.

Twitter API

Twitter API

UNITY 3D scripting reference (Their API is just as confusing)

UNITY 3D scripting reference (Their API is just as confusing)

No thank you.

No thank you.

This is one is designed by the CODEA APP developers. A bit better.

This is one is designed by the CODEA APP developers. A bit better.

One major issue with most APIs is that the way they name their variables and functions and classes is unintuitive.

Just about every API I have tried to use has a very confusing and un-organized setup. And it is hard to find anything I want easily. So I thought of a neater way to display an API to users.

Instead of using an OUTLINE format, it is better to use a TABLE format for your API. Organizing CLASSES, FUNCTIONS, AND VARIABLES into tables is easier to read than an outline with multiple links.

I will make a sample GAME ENGINE API

This is an ANIMATION CLASS. Inside of it are three functions. JUMP, MOVE, and SPIN are the three functions. Make the function names easy to understand. I can easily tell what these functions do.

This is an ANIMATION CLASS. Inside of it are three functions. JUMP, MOVE, and SPIN are the three functions. Make the function names easy to understand. I can easily tell what these functions do.

Clicking on the MOVE function takes you to another table.

NOTE: A period at the end of a word signifies it is a CLASS. A period at the beginning of a word signifies it is part of a class.

Inside of the MOVE function are several variables. Button, Direction, Speed, Animation, and Sound are the variables inside of the MOVE function. You can also adjust variables from the table.

Inside of the MOVE function are several variables. Button, Direction, Speed, Animation, and Sound are the variables inside of the MOVE function. You can also adjust variables from the table.

As a sentence this function would "Move, using the "RIGHT" button in the "0" direction with a speed of "4" while playing the "walk" animation and the "walking" sound."

This is the JUMP function

This is the JUMP function

And this is the SPIN function. Notice how LOOP is a BOOLEAN variable. SPEED is a FLOAT variable.

And this is the SPIN function. Notice how LOOP is a BOOLEAN variable. SPEED is a FLOAT variable.

Games have several key parts. The ANIMATION class animates stuff.

The SOUND CLASS handles sounds. This class has a SOUND variable and a LOOP variable. It also has a PLAY function and a STOP function.

The SOUND CLASS handles sounds. This class has a SOUND variable and a LOOP variable. It also has a PLAY function and a STOP function.

We need objects in the game to give animations and sounds to.

OBJECT CLASS. Static or unintelligent things should be a part of the OBJECT class.

OBJECT CLASS. Static or unintelligent things should be a part of the OBJECT class.

And we need CHARACTERS. These are very advanced objects. These are objects with intelligence.

CHARACTER CLASS.

CHARACTER CLASS.

LIGHTS.CAMERAS.ACTION.

LIGHT CLASS

LIGHT CLASS

CAMERA CLASS

CAMERA CLASS

CUTSCENE CLASS

CUTSCENE CLASS

Every game has a menu!

MENU CLASS

MENU CLASS

Now we put our animated objects with sound and lights into a LEVEL!

LEVEL CLASS. See how the objects are already organized by their CLASS? The "STUDIO" sound is from the "LIGHTS" class. STUDIO LIGHTS!

LEVEL CLASS. See how the objects are already organized by their CLASS? The "STUDIO" sound is from the "LIGHTS" class. STUDIO LIGHTS!

Bring it all together with a STORYBOARD CLASS

The STORYBOARD CLASS is like the CONTROL CENTER for your game or game engine. It organizes the events of your game. So this game has a CUSTSCENE followed by a MENU and then by a LEVEL.

The STORYBOARD CLASS is like the CONTROL CENTER for your game or game engine. It organizes the events of your game. So this game has a CUSTSCENE followed by a MENU and then by a LEVEL.

You can also put comments at the bottom of your tables with detailed information on how things work.

Of course, your info would be more detailed. Perhaps a few examples on how the classes work would be included.

Of course, your info would be more detailed. Perhaps a few examples on how the classes work would be included.

  • Understanding of computer programming