Giter Site home page Giter Site logo

glitch.js's Introduction

glitchapi.js

⚠️ Important Information ⚠️

Do not store insecurely or share the persitent token or the temporary login code. As far as I know, Glitch does not refresh the token in anyway or the login code. The only way to refresh the login code is by requesting a new one.

Doing so puts your account at risk and potentially your private information.

Install

npm install glitchapi.js

General Examples

Get Project By ID or Name

const Glitch = require('glitchapi.js');
(async () => {
    // Get project by domain name
    console.log(await Glitch.getProject("domain", "stay-safe-discord"));
    // Get project by id
    console.log(await Glitch.getProject("id", "e292e1a7-9130-4150-abd3-90b893a95858"));
})()

Get User by ID or Login/@

const Glitch = require('glitchapi.js');
(async () => {
    // Get project by domain name
    console.log(await Glitch.getUser("login", "Zaedus"));
    // Get project by id
    console.log(await Glitch.getUser("id", 2643102));
})()

Logged in User Examples

Getting a login token

const Glitch = require('glitchapi.js');

Glitch.emailTempCode("[email protected]");

Check your email and you will find your code.

cringe

MAKE SURE YOU STORE IT SECURELY

Logging in

Creates a Me instance.

const Glitch = require('glitchapi.js');

const me = new Glitch.Me();

me.on("ready", () => {
    console.log(`${me.name} (@${me.login})`) // Zaedus (@Zaedus)
})

me.signin("your-code-here")

Setting User Data

Sets various attributes about the user's account like the name, @, and description.

const Glitch = require('glitchapi.js');

const me = new Glitch.Me();

me.on("ready", async () => {
    await me.update({
        avatarUrl: "https://i.ytimg.com/vi/YBXLVex9FtQ/maxresdefault.jpg", // Must be an online URL
        description: "This discription was set with API!", // Sets your description
        hasCoverImage: true, // Shows or hides the background image
        name: "MyNewName", // Sets your display name
        login: "MyNewAt" // Sets your @
    })
    console.log("User data updated!");
})

me.signin("your-code-here")

Creating a Project

Creates a new projects called "my-new-express-app".

const Glitch = require('glitchapi.js');

const me = new Glitch.Me();

me.on("ready", async () => {
    await me.remix("hello-express", {
        domain: "my-new-express-app",
        description: "My new express app!",
        private: false
    })
    console.log("New project created!");
})

me.signin("your-code-here")

Getting Your Projects

Gets 10 projects and logs the URL associated with them.

const Glitch = require('glitchapi.js');

const me = new Glitch.Me();

me.on("ready", async () => {
    const projects = await me.getProjects(10);
    projects.forEach(p => {
        console.log("https://" + p.domain + ".glitch.me/");
    });
})

me.signin("your-code-here")

Updating Project Data

const Glitch = require('glitchapi.js');

const me = new Glitch.Me();

me.on("ready", async () => {
    const projects = await me.getProjects(10);
    await projects[0].update({
        domain: "my-new-domain",
        description: "Successfully updated!"
    })
    console.log("Project updated!");
})

me.signin("your-code-here")

Project Deletion/Undeletion

const Glitch = require('glitchapi.js');

const me = new Glitch.Me();

me.on("ready", async () => {
    const projects = await me.getProjects(10);
    projects[0].delete();
    setTimeout(() => projects[0].undelete(), 2000);
})

me.signin("your-code-here")

glitch.js's People

Contributors

zaedus avatar dependabot[bot] avatar

Stargazers

Senchabot avatar YoungChief avatar  avatar Sudhan avatar Khaleel Gibran avatar David M avatar ${Mr.DJA} avatar

Watchers

 avatar  avatar

glitch.js's Issues

A problem with 'project.undelete()'.

var project = ((await me.getProjects()).filter(project => project.domain === 'some-name'))[0];
project.delete();
setTimeout(() => project.undelete(), 2000); //(node:8910) UnhandledPromiseRejectionWarning: Error: Request failed with status code 404

Is that bug or what?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.