Skip to content

Instantly share code, notes, and snippets.

@xgqfrms-GitHub
Last active November 10, 2020 14:54
Show Gist options
  • Save xgqfrms-GitHub/d3f1ac685335d481572d5390d7c31a1c to your computer and use it in GitHub Desktop.
Save xgqfrms-GitHub/d3f1ac685335d481572d5390d7c31a1c to your computer and use it in GitHub Desktop.
GitHub GraphQL API

github API

GitHub GraphQL API

let username = `xgqfrms-GitHub`;
    repo = `Node-CLI-Tools/commits`;


const url = `https://api.github.com/repos/${username}/${repo}`;

// https://api.github.com/repos/xgqfrms-GitHub/Node-CLI-Tools/commits

// Error API: https://api.github.com/users/${username}/${repo}


fetch(`https://api.github.com/repos/${username}/${repo}`,{
    data: {
        client_id: '08ecc2f68d922f1????',
        client_secret: '5846d428b5340812b76c9637eceaee97934????'
    }
})
.then((response) => response.json())
.then((json)=> {
    console.log(`json = ${json}`);
    return repos = json;
})
.then((repos)=>{
    console.log(`repos = ${repos}`);
    console.log(`repos = ${repos.length}`);
    console.log(`repos$ 0  = ${repos[0]}`);
    console.log(`repos$ 1  = ${repos[1]}`);
    for (let i = 0; i < repos.length; i++) {
        console.log(`repos${i}  = ${repos[i]}`);
    }
});

// https://api.github.com/users/xgqfrms

// https://api.github.com/users/xgqfrms/react2 ???





let nct = ((username=`xgqfrms-GitHub`, repo=`Node-CLI-Tools`) => {
    fetch(`https://api.github.com/repos/${username}/${repo}/commits`,{
        data: {
            client_id: '08ecc2f68d922f1????',
            client_secret: '5846d428b5340812b76c9637eceaee97934????'
        }
    })
    .then((response) => response.json())
    .then((json)=> {
        return repos = json;
    })
    .then((repos)=>{
        console.log(repos);
    });
})();


/*

API

https://developer.github.com/v3/repos/

https://developer.github.com/v3/users/

https://developer.github.com/v3/repos/#list-user-repositories

https://developer.github.com/v3/repos/#list-organization-repositories

*/

fetch(`https://api.github.com/orgs/webgeeker/repos/`,{
    data: {
        client_id: '08ecc2f68d922f1????',
        client_secret: '5846d428b5340812b76c9637eceaee97934????'
    }
})
.then((response) => response.json())
.then((json)=> {
    console.log(`json = ${json}`);
    return repos = json;
});





fetch(`https://api.github.com/users`,{
    data: {
        client_id: '08ecc2f68d922f1????',
        client_secret: '5846d428b5340812b76c9637eceaee97934????'
    }
})
.then((response) => response.json())
.then((json)=> {
    console.log(`json = ${json}`);
    return repos = json;
});




fetch(`https://api.github.com/users/xgqfrms`,{
    data: {
        client_id: '08ecc2f68d922f1????',
        client_secret: '5846d428b5340812b76c9637eceaee97934????'
    }
})
.then((response) => response.json())
.then((json)=> {
    console.log(`json = ${json}`);
    return repos = json;
});

GraphQL API

https://developer.github.com/v4/

数据脱敏

https://gist.github.com/xgqfrms-GitHub/d3f1ac685335d481572d5390d7c31a1c