β‘Running glifs via the API
The Glif API is in early beta, but weβre excited to see what y'all build.
During limited beta, the Glif API is free and has relatively low rate limits. This is all subject to change. If you're building with our API, please join our Discord or get in touch since we'd love to chat and learn more about what you're building.
Some glif-powered things:
@jamiedubs made a 'bell curve' twitter bot: https://twitter.com/bellcurvebot
@fab1an made an interactive blog post https://glifblog.replit.app/
@tanaki is a glif-powered noodley virtual being: https://tiktok.com/@hellotanaki
Running glifs using the Simple API
The Simple API requires an API token to make requests
Hereβs the expected output of that command:
You're most likely interested in the output
field, which is the final output of the glif.
outputFull
is a JSON object with more info about the final output, including it's type.
If thereβs an error itβll be in an error
field, but the response will have a "200 OK" status code. For legacy reasons the the Simple API always returns 200 OK. This might change in the future.
Parameters
id
You can put the glif id in the url:
Or put it in the body:
inputs
for now only strings values are allowed
You can either use a positional array:
Or name your parameters. The names have to correspond to your glif-block names. If you don't know the parameter names, check out Looking up the internal names of a glif's inputs.
Looking up the internal names of a glif's inputs
To specify named parameters, you need to use the internal block name. This has no spaces and usually is something like "text1", "multipick2", but each glif creator can customize it.
On the glif.app website you can look at the block names in the "View source" page of a glif, like this one:
Or you can look at the nodes
field of a glif's data via our API:
https://glif.app/api/glifs?id=clkbasluf0000mi08h541a3j4 This glif has blocks with the names:
Lastly, you can use the commandline to fetch field names dynamically using curl
+ jq
:
here's the output:
meaning this glif requires two inputs, input1
and image1
. We plan to improve this in the near future.
β οΈ Strict mode and default glif input value substitution
If you do not provide enough inputs, the default values in the glif values will be automatically substituted.
So if you specify arg1, that'll be used, but if it requires arg1 and arg2, it'll use your arg1 but use the defualt value for arg2.
If you'd prefer to have API calls with insufficient inputs to fail, append ?strict=1
to your URLs, e.g. https://simple-api.glif.app?strict=1
β οΈ CORS (cross-origin requests)
CORS is allowed by the Simple API, but not by our other API endpoints. You'll need to make your own serverside wrappers for these cases.
Last updated