🥞
Glif Docs/Guide
  • Getting Started
    • 👋What is Glif?
    • 💡What can I do with a glif?
      • 🏃Run a glif
      • 🔌Build a glif
      • 🔀Remix a glif
      • 🗣️Comment on a glif
      • 🔳Embed a glif
    • ⚒️How do I build a glif?
      • 📽️Video tutorial: Building a simple image generator
      • 🟰Using variables
    • ⚙️Profile Settings
    • 🪙Credits and Payments
    • ❓FAQs
  • Blocks
    • 🙋Inputs
      • ✍️Text Input Block
      • 🖼️Image Input Block
      • 📋Multipick Block
    • 🪄Generators
      • 📃Text Block
      • 🖼️Image Block
      • ➡️Image to Text Block
        • Florence2Sam2Segmenter
    • 🧰Tools
      • 🔀Text Combiner Block
      • 🔬JSON Extractor Block
    • 💅Styling
      • 🎨HTML Block
      • 🖼️Canvas Block
    • 🧑‍🔬Advanced/Experimental
      • 🎙️Audio Input Block
      • ↔️Glif Block
      • 🌐Web Fetcher Block
      • 🔊Audio Spell
      • 🧱ComfyUI Block
      • 📡Audio to Text Block
      • 🎥Video Input Block
      • 🔧JSON Repair Block
  • Apps
    • 🎨Glif It! Browser Extension
  • Glif University
    • 🎥Video Tutorials
      • 🐲How To: D&D Character Sheet Generator
      • 🧠How To: Expanding Brain Meme Generator
      • 🦑How To: Occult Memelord Generator
      • 🥸How To: InstantID Portrait Restyle Glif
      • 🕺How To: Style and Pose a Character with InstantID + Controlnet
      • 😱How To: Create a Simple Cartoon Portrait Animation Glif (LivePortrait + Custom Blocks)
      • 👗How to Create a Clothing Restyler App (IP Adapter, ControlNet + GPT Vision)
      • 🤡How to Create a 4+ Panel Storyboard/Comic (Flux Schnell)
      • 🎂How to Create a Recipe Generator with Accompanying Pictures
      • How to Use JasperAI Depth Controlnet on Flux Dev
      • 🦸‍♂️How to Make a Consistent Comic Panel Generator
    • 🧑‍🏫Prompt Engineering 101
    • 🖼️ControlNet
    • 📚AI Glossary
  • API - for Developers
    • ⚡Running glifs via the API
    • 🤖Using AI Assistants to build with the Glif API
    • 📙Reading & writing data via the API
    • 🗾Glif Graph JSON Schema
    • 📫Embed player & custom webpages
    • 📫Sample code
    • ❓What can I make with the Glif API?
      • Browser Extensions
      • Discord Bots
      • Games
      • Social Media Bots
      • Experimental Projects
  • Policies
    • 👨‍👩‍👧‍👦Community Guidelines
  • Programs
    • 🖼️Loradex Trainer Program
  • Community Resources
    • 🧑‍🤝‍🧑Resources Created by Glif Community Members
  • Contact Us
    • 📣Send us your feedback
    • 🚔Information for law enforcement
Powered by GitBook
On this page
  • Individual glif
  • Lists of glifs
  • Runs for a given glif
  • Create a glif
  • User info
  • Spheres (beta)
  • Help/Support/Questions
  1. API - for Developers

Reading & writing data via the API

PreviousUsing AI Assistants to build with the Glif APINextGlif Graph JSON Schema

Last updated 14 days ago

Glif API is in beta and subject to change.

For fetching info about a specific glif, user, or a specific glifRun.

Paginate using ?page= when applicable. You can also increase the # of results per page using e.g. ?limit=50, currently defaulting to 20 and capped at 100

Individual glif

Fetch a specific glif: GET

Includes full glif-graph JSON in the data field

Lists of glifs

Fetch all public glifs: GET

Fetch featured glifs on homepage: GET

Fetch user's glifs by username: GET

Fetch user's glifs by user ID: GET

To get the full glif-graph JSON in the data field, append ?includes=spells.data

Runs for a given glif

Fetch a specific run: GET

Fetch all public runs by a specific user:

Create a glif

Here's a curl example which creates an empty, unpublished (draft) glif:

curl -X POST "https://glif.app/api/glifs" \
     -H "Authorization: Bearer $GLIF_API_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "name": "API test glif",
       "description": "just testing :)",
       "graph": {"nodes": []}
     }'

Please note that formatting complex JSON inside a shell command like this is a huge pain in the butt and is not recommended for serious development :)

curl -X POST "https://glif.app/api/glifs" \
  -H "Authorization: Bearer $GLIF_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "API test glif 2",
    "description": "just testing again, I love APIs",
    "graph": {
      "nodes": [
        {
          "name": "query",
          "type": "TextInputBlock",
          "params": {
            "label": "query",
            "value": "what is trending in pop culture this week?"
          }
        },
        {
          "name": "result",
          "type": "GPTBlock",
          "params": {
            "model": "Perplexity: Llama3 Sonar 8B Online",
            "prompt": "{query}",
            "jsonMode": false,
            "maxTokens": 1000,
            "temperature": 0.2,
            "systemPrompt": "You are a helpful assistant."
          }
        }
      ]
    }
  }'

Here's an example response on success for that call:

{"id":"clzs7eoan0003n1xgod8grhaj","name":"API test glif 2","imageUrl":null,"description":"just testing again, I love APIs","createdAt":"2024-08-13T09:12:02.688Z","updatedAt":"2024-08-13T09:12:02.688Z","publishedAt":null,"output":null,"outputType":null,"forkedFromId":null,"featuredAt":null,"userId":"clcu26uxx0000lc08mqnjf5mq","completedSpellRunCount":0,"averageDuration":null,"user":{"id":"clcu26uxx0000lc08mqnjf5mq","name":"jamiedubs","image":"https://res.cloudinary.com/dzkwltgyd/image/upload/v1709593997/user-image-production/ckkbd7jmxly9ms0csaxv.jpg","username":"jamiedubs"},"_count":{"likes":0,"comments":0},"spheres":[],"data":{"nodes":[{"name":"query","type":"TextInputBlock","params":{"label":"query","value":"what is trending in pop culture this week?"}},{"name":"result","type":"GPTBlock","params":{"model":"Perplexity: Llama3 Sonar 8B Online","prompt":"{query}","jsonMode":false,"maxTokens":1000,"temperature":0.2,"systemPrompt":"You are a helpful assistant."}}]}}

Note the glif id, clzs7eoan0003n1xgod8grhaj. Also note that this glif is also unpublished and so it is not accessible to any user except you! You can publish it via the website, or by specifying a "publishedAt" date in your POST request.

You can then run it this glif:

curl -X POST "https://simple-api.glif.app" \
  -H "Authorization: Bearer $GLIF_API_TOKEN" \
  -d '{"id": "clzs7eoan0003n1xgod8grhaj", "query": "who is the coolest software developer of all time?"'}

To view raw glif data, you can fork or build something on glif.app and use the "Debug" button bottom-left.

Alternately, it's present in all published glifs via the API, e.g., in order of increasing complexity:

User info

Fetch info about a user, via either ID or username:

Spheres (beta)

You can also use ?id= param

Like the 'list of glifs' above, you can fetch the full glif-graph JSON in these list queries by appending ?includes=spells.data

Help/Support/Questions

Fetch all public runs for a specific glif: GET (?spellId= also works)

by username: GET

by userId: GET

Currently in private testing; if you're messing with this!

Here's a curl example that includes one text input and an LLM call (GPTBlock) copied from this glif.

Simple text generator:

Audio input with CanvasBlock formatting:

ComfyUI-based image transformer:

Fetch info about the logged-in user (and thus test that your API token is working and you are logged-in): GET

GET

GET

To get glifs from a specific sphere (AKA folder or collection): GET

Public spheres are listed on

Please and post in the #api-support channel if you have any questions or need help with the API. We'd love to hear from you!

Alternately you can , but those will get slower replies.

📙
https://glif.app/api/glifs?id=clgh1vxtu0011mo081dplq3xs
https://glif.app/api/glifs
https://glif.app/api/glifs?featured=1
https://glif.app/api/glifs?username=jamiedubs
https://glif.app/api/glifs?userId=clcu26uxx0000lc08mqnjf5mq
https://glif.app/api/runs?id=i3kqrilvp6rmsszwnw44ycyl
https://glif.app/api/runs?glifId=clgh1vxtu0011mo081dplq3xs
https://glif.app/api/runs?username=jamiedubs
https://glif.app/api/runs?userId=clcu26uxx0000lc08mqnjf5mq
contact us
Perplexity search
https://glif.app/api/glifs?id=clzs7eoan0003n1xgod8grhaj
https://glif.app/api/glifs?id=clyimuesi0009445j4laxm8o1
https://glif.app/api/glifs?id=clz0e47iu0002vr1lyyuwdl0x
https://glif.app/api/me
https://glif.app/api/user?username=jamiedubs
https://glif.app/api/user?id=clcu26uxx0000lc08mqnjf5mq
https://glif.app/api/spheres?slug=memes
https://glif.app/spheres
join our Discord
contact us via email