APIthon Reference
How APIthon Works
The most important thing to remember about APIthon is that it returns the result from the last line of code
Let’s look at some examples:
This will give us back 8, because adding cookies is the last thing we did! But if we write:
We won’t get anything back, because the last thing we did was just make a new variable!
Python vs. APIthon
Capabilities
- No Imports
- You cannot import any external modules or packages
- You can only use the built-in functions that are available
- No Classes
- You cannot define new classes
- You must work with existing data types
- No Private Methods or Properties
- Anything that starts with an underscore (_) is off-limits
- This includes both methods and variables
- No External Code
- All code must be self-contained
- No accessing external resources
- No Multiple Language Support
- APIthon only works with Python-style syntax
- No mixing with other programming languages
Size Limits
APIthon also has some size limits:
- Your code can’t be too long (4096 bytes)
- Your lists can’t have too many things in them (2096 bytes)
- Your numbers can’t be too big or too small (4294967296)
- Your words (strings) can’t be too long (4096 bytes/characters)
Using APIthon
Common Operations
APIthon supports many common operations across different data types. Here are the most useful ones you’ll likely use:
Working with Numbers (Integers and Floats)
Working with Text (Strings)
Working with Lists
Working with Sets
Working with Dictionaries
Common Built-in Functions
Remember these important points about functions in APIthon:
- All functions return values (just like in a Python shell)
- The last operation’s result is what gets returned
- There are limits on how many operations you can perform
- If a function name starts with underscore (_), you can’t use it
APIthon Examples
Example 1: Joining a list of strings
This takes a list of names and join them together into a single string!
Sample Input Payload:
Result:
Example 2: Calculating Total Points
This adds up all the positive scores in a list!
Sample Input Payload:
Result:
Example 3: Organizing a Pet Directory
This organizes a list of pets by type and creates a nice summary!
Sample Input Payload:
Result:
Example 4: Grade Calculator
This takes a list of grades, calculates statistics, and creates a detailed report!
Sample Input Payload:
Result:
Troubleshooting
- Remember to use
|aftercode:to tell the editor that you’re about to write multiline code - Make sure your indentation is correct - Python is very picky about this!
- The last line of your code is what gets saved to your
output_key - Be aware of the size limits when working with collections